25 lines
512 B
Go
25 lines
512 B
Go
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)
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|