2024-10-02 02:56:25 +00:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
2024-10-03 03:03:57 +00:00
|
|
|
"context"
|
2024-10-02 02:56:25 +00:00
|
|
|
"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()
|
|
|
|
|
2024-10-03 03:03:57 +00:00
|
|
|
ServiceList(resp, req, context.Background())
|
2024-10-02 02:56:25 +00:00
|
|
|
|
|
|
|
response := resp.Result()
|
|
|
|
|
|
|
|
if response.StatusCode != 501 {
|
|
|
|
t.Errorf("Expected status 501, got %d.", response.StatusCode)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|