Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Snider <jsnider@mtu.edu>
  • Loading branch information
jsnider-mtu committed Mar 9, 2021
1 parent 2314973 commit b0fd240
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/engine/apiPath_test.go
Expand Up @@ -26,3 +26,26 @@ func Test_Paths(t *testing.T) {
f("/apis/gloo.solo.io/v1/namespaces/gloo-system/upstreams/ ", "/apis/gloo.solo.io/v1/namespaces/gloo-system/upstreams")
f(" /apis/gloo.solo.io/v1/namespaces/gloo-system/upstreams", "/apis/gloo.solo.io/v1/namespaces/gloo-system/upstreams")
}

func Test_GroupVersions(t *testing.T) {
f := func(path, expected string) {
p, err := NewAPIPath(path)
if err != nil {
t.Error(err)
return
}

if p.Root == "api" {
if p.Group != expected {
t.Errorf("expected %s got %s", expected, p.Group)
}
} else {
if p.Version != expected {
t.Errorf("expected %s got %s", expected, p.Version)
}
}
}

f("/api/v1/namespace/{{ request.namespace }}", "v1")
f("/apis/extensions/v1beta1/namespaces/example/ingresses", "extensions/v1beta1")
}

0 comments on commit b0fd240

Please sign in to comment.