From b540f681b4cdf740f9b8d1e584fd2b107fc1b090 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 1 Dec 2020 20:42:21 +0100 Subject: started to clean-up instance Things like opening files is better place in the server package. Any code that is difficult to test should also not be in the STFE package. --- handler_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'handler_test.go') diff --git a/handler_test.go b/handler_test.go index 689541b..3bcc702 100644 --- a/handler_test.go +++ b/handler_test.go @@ -43,17 +43,17 @@ func newTestHandler(t *testing.T, signer crypto.Signer) *testHandler { } } -func (th *testHandler) getHandlers(t *testing.T) map[Endpoint]handler { - return map[Endpoint]handler{ - EndpointGetSth: handler{instance: th.instance, handler: getSth, endpoint: EndpointGetSth, method: http.MethodGet}, - EndpointGetConsistencyProof: handler{instance: th.instance, handler: getConsistencyProof, endpoint: EndpointGetConsistencyProof, method: http.MethodGet}, - EndpointGetProofByHash: handler{instance: th.instance, handler: getProofByHash, endpoint: EndpointGetProofByHash, method: http.MethodGet}, - EndpointGetAnchors: handler{instance: th.instance, handler: getAnchors, endpoint: EndpointGetAnchors, method: http.MethodGet}, - EndpointGetEntries: handler{instance: th.instance, handler: getEntries, endpoint: EndpointGetEntries, method: http.MethodGet}, +func (th *testHandler) getHandlers(t *testing.T) map[Endpoint]Handler { + return map[Endpoint]Handler{ + EndpointGetSth: Handler{instance: th.instance, handler: getSth, endpoint: EndpointGetSth, method: http.MethodGet}, + EndpointGetConsistencyProof: Handler{instance: th.instance, handler: getConsistencyProof, endpoint: EndpointGetConsistencyProof, method: http.MethodGet}, + EndpointGetProofByHash: Handler{instance: th.instance, handler: getProofByHash, endpoint: EndpointGetProofByHash, method: http.MethodGet}, + EndpointGetAnchors: Handler{instance: th.instance, handler: getAnchors, endpoint: EndpointGetAnchors, method: http.MethodGet}, + EndpointGetEntries: Handler{instance: th.instance, handler: getEntries, endpoint: EndpointGetEntries, method: http.MethodGet}, } } -func (th *testHandler) getHandler(t *testing.T, endpoint Endpoint) handler { +func (th *testHandler) getHandler(t *testing.T, endpoint Endpoint) Handler { handler, ok := th.getHandlers(t)[endpoint] if !ok { t.Fatalf("no such get endpoint: %s", endpoint) @@ -61,13 +61,13 @@ func (th *testHandler) getHandler(t *testing.T, endpoint Endpoint) handler { return handler } -func (th *testHandler) postHandlers(t *testing.T) map[Endpoint]handler { - return map[Endpoint]handler{ - EndpointAddEntry: handler{instance: th.instance, handler: addEntry, endpoint: EndpointAddEntry, method: http.MethodPost}, +func (th *testHandler) postHandlers(t *testing.T) map[Endpoint]Handler { + return map[Endpoint]Handler{ + EndpointAddEntry: Handler{instance: th.instance, handler: addEntry, endpoint: EndpointAddEntry, method: http.MethodPost}, } } -func (th *testHandler) postHandler(t *testing.T, endpoint Endpoint) handler { +func (th *testHandler) postHandler(t *testing.T, endpoint Endpoint) Handler { handler, ok := th.postHandlers(t)[endpoint] if !ok { t.Fatalf("no such post endpoint: %s", endpoint) -- cgit v1.2.3