aboutsummaryrefslogtreecommitdiff
path: root/instance_test.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-12-01 15:34:55 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-12-01 15:34:55 +0100
commit6cd12911f4d3aa4c6a75c922f9de231e2cf309dd (patch)
treea5a39e7e41d4354b8489ae531435c032870ded56 /instance_test.go
parent7fd9d2f727a8acf43bb6312888c1450ed2a1eb60 (diff)
attached url method on endpoint type
Diffstat (limited to 'instance_test.go')
-rw-r--r--instance_test.go40
1 files changed, 40 insertions, 0 deletions
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)
+ }
+ }
+}