1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

refactor(edge/stacks): separate create by method [EE-4947] (#8898)

This commit is contained in:
Chaim Lev-Ari 2023-05-04 21:11:19 +07:00 committed by GitHub
parent 1ff19f8604
commit 426c132f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1225 additions and 1123 deletions

View file

@ -0,0 +1,39 @@
package edgestacks
import (
"net/http"
"net/http/httptest"
"testing"
)
// Inspect
func TestInspectInvalidEdgeID(t *testing.T) {
handler, rawAPIKey, teardown := setupHandler(t)
defer teardown()
cases := []struct {
Name string
EdgeStackID string
ExpectedStatusCode int
}{
{"Invalid EdgeStackID", "x", 400},
{"Non-existing EdgeStackID", "5", 404},
}
for _, tc := range cases {
t.Run(tc.Name, func(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, "/edge_stacks/"+tc.EdgeStackID, nil)
if err != nil {
t.Fatal("request error:", err)
}
req.Header.Add("x-api-key", rawAPIKey)
rec := httptest.NewRecorder()
handler.ServeHTTP(rec, req)
if rec.Code != tc.ExpectedStatusCode {
t.Fatalf("expected a %d response, found: %d", tc.ExpectedStatusCode, rec.Code)
}
})
}
}