spud/daemon/api_test.go

26 lines
512 B
Go
Raw Normal View History

2024-10-02 02:56:25 +00:00
package daemon
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestServiceListUnsupportedMethods(t *testing.T) {
for _, method := range []string{http.MethodGet, http.MethodPut, http.MethodHead} {
t.Run(method, func(t *testing.T) {
req := httptest.NewRequest(method, "/service", nil)
resp := httptest.NewRecorder()
ServiceList(resp, req)
response := resp.Result()
if response.StatusCode != 501 {
t.Errorf("Expected status 501, got %d.", response.StatusCode)
}
})
}
}