diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-01 21:37:54 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-01 21:37:54 +0200 |
commit | 2dcaf038655426c572c5d292973001c581f0a1a2 (patch) | |
tree | f52f2c93404a3f13e590c4af87ff349d563eae14 /types/types_test.go | |
parent | 2c2c6936a93ce4f18302426a665ed5782910ab85 (diff) |
moved endpoint type into types
Diffstat (limited to 'types/types_test.go')
-rw-r--r-- | types/types_test.go | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/types/types_test.go b/types/types_test.go new file mode 100644 index 0000000..9d76c73 --- /dev/null +++ b/types/types_test.go @@ -0,0 +1,53 @@ +package types + +import ( + "testing" +) + +func TestEndpointPath(t *testing.T) { + base, prefix, proto := "example.com", "log", "st/v0" + for _, table := range []struct { + endpoint Endpoint + want string + }{ + { + endpoint: EndpointAddLeaf, + want: "example.com/log/st/v0/add-leaf", + }, + { + endpoint: EndpointAddCosignature, + want: "example.com/log/st/v0/add-cosignature", + }, + { + endpoint: EndpointGetTreeHeadLatest, + want: "example.com/log/st/v0/get-tree-head-latest", + }, + { + endpoint: EndpointGetTreeHeadToSign, + want: "example.com/log/st/v0/get-tree-head-to-sign", + }, + { + endpoint: EndpointGetTreeHeadCosigned, + want: "example.com/log/st/v0/get-tree-head-cosigned", + }, + { + endpoint: EndpointGetConsistencyProof, + want: "example.com/log/st/v0/get-consistency-proof", + }, + { + endpoint: EndpointGetProofByHash, + want: "example.com/log/st/v0/get-proof-by-hash", + }, + { + endpoint: EndpointGetLeaves, + want: "example.com/log/st/v0/get-leaves", + }, + } { + if got, want := table.endpoint.Path(base+"/"+prefix+"/"+proto), table.want; got != want { + t.Errorf("got endpoint\n%s\n\tbut wanted\n%s\n\twith one component", got, want) + } + if got, want := table.endpoint.Path(base, prefix, proto), table.want; got != want { + t.Errorf("got endpoint\n%s\n\tbut wanted\n%s\n\tmultiple components", got, want) + } + } +} |