From 6cd12911f4d3aa4c6a75c922f9de231e2cf309dd Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 1 Dec 2020 15:34:55 +0100 Subject: attached url method on endpoint type --- instance_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'instance_test.go') diff --git a/instance_test.go b/instance_test.go index 7facdd6..6fe0e5b 100644 --- a/instance_test.go +++ b/instance_test.go @@ -38,3 +38,43 @@ func makeTestLogParameters(t *testing.T, signer crypto.Signer) *LogParameters { HashType: testHashType, } } + +func TestEndpointUrl(t *testing.T) { + base, prefix := "http://example.com", "test" + for _, table := range []struct { + endpoint Endpoint + want string + }{ + { + endpoint: EndpointAddEntry, + want: "http://example.com/test/add-entry", + }, + { + endpoint: EndpointGetEntries, + want: "http://example.com/test/get-entries", + }, + { + endpoint: EndpointGetProofByHash, + want: "http://example.com/test/get-proof-by-hash", + }, + { + endpoint: EndpointGetConsistencyProof, + want: "http://example.com/test/get-consistency-proof", + }, + { + endpoint: EndpointGetSth, + want: "http://example.com/test/get-sth", + }, + { + endpoint: EndpointGetAnchors, + want: "http://example.com/test/get-anchors", + }, + } { + if got, want := table.endpoint.Url(base, prefix), table.want; got != want { + t.Errorf("got %s but wanted %s with multiple components", got, want) + } + if got, want := table.endpoint.Url(base+"/"+prefix), table.want; got != want { + t.Errorf("got %s but wanted %s with one component", got, want) + } + } +} -- cgit v1.2.3