Files
threshold/internal/servers/controller/handler_test.go
T

41 lines
806 B
Go
Raw Normal View History

2020-05-01 12:38:01 -07:00
package controller
import (
"fmt"
"net/http"
"testing"
)
func TestHandleGrpcGateway(t *testing.T) {
2020-06-05 11:52:59 -07:00
c := NewTestController(t, nil)
defer c.Shutdown()
2020-05-01 12:38:01 -07:00
cases := []struct {
name string
path string
code int
}{
{
"Non existent path",
"v1/this-is-made-up",
http.StatusNotFound,
},
{
"Unimplemented path",
2020-05-12 17:35:48 -07:00
"v1/orgs/1/projects/2/host-catalogs/3/host-sets/4",
2020-05-26 17:11:29 -07:00
http.StatusMethodNotAllowed,
2020-05-01 12:38:01 -07:00
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
2020-06-05 11:52:59 -07:00
url := fmt.Sprintf("%s/%s", c.ApiAddrs()[0], tc.path)
2020-05-01 12:38:01 -07:00
resp, err := http.Get(url)
if err != nil {
t.Errorf("Got error: %v when non was expected.", err)
}
if got, want := resp.StatusCode, tc.code; got != want {
t.Errorf("GET on %q got code %d, wanted %d", tc.path, got, want)
}
})
}
}