1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

refactor(stacks): break swagger docs by type [EE-5381] (#8820)

This commit is contained in:
Chaim Lev-Ari 2023-04-27 11:03:55 +07:00 committed by GitHub
parent bbea0bc8a5
commit 77f8b9333a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 347 additions and 144 deletions

View file

@ -237,7 +237,7 @@ func TestCreateAndInspect(t *testing.T) {
r := bytes.NewBuffer(jsonPayload)
// Create EdgeStack
req, err := http.NewRequest(http.MethodPost, "/edge_stacks?method=string", r)
req, err := http.NewRequest(http.MethodPost, "/edge_stacks/create/string", r)
if err != nil {
t.Fatal("request error:", err)
}
@ -290,37 +290,32 @@ func TestCreateWithInvalidPayload(t *testing.T) {
cases := []struct {
Name string
Payload interface{}
QueryString string
ExpectedStatusCode int
Method string
}{
{
Name: "Invalid query string parameter",
Name: "Invalid method parameter",
Payload: swarmStackFromFileContentPayload{},
QueryString: "invalid=query-string",
Method: "invalid",
ExpectedStatusCode: 400,
},
{
Name: "Invalid creation method",
Payload: swarmStackFromFileContentPayload{},
QueryString: "method=invalid-creation-method",
ExpectedStatusCode: 500,
},
{
Name: "Empty swarmStackFromFileContentPayload with string method",
Payload: swarmStackFromFileContentPayload{},
QueryString: "method=string",
Method: "string",
ExpectedStatusCode: 400,
},
{
Name: "Empty swarmStackFromFileContentPayload with repository method",
Payload: swarmStackFromFileContentPayload{},
QueryString: "method=repository",
Method: "repository",
ExpectedStatusCode: 400,
},
{
Name: "Empty swarmStackFromFileContentPayload with file method",
Payload: swarmStackFromFileContentPayload{},
QueryString: "method=file",
Method: "file",
ExpectedStatusCode: 400,
},
{
@ -331,7 +326,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
EdgeGroups: edgeStack.EdgeGroups,
DeploymentType: edgeStack.DeploymentType,
},
QueryString: "method=string",
Method: "string",
ExpectedStatusCode: 500,
},
{
@ -342,7 +337,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
EdgeGroups: []portainer.EdgeGroupID{},
DeploymentType: edgeStack.DeploymentType,
},
QueryString: "method=string",
Method: "string",
ExpectedStatusCode: 400,
},
{
@ -353,7 +348,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
EdgeGroups: []portainer.EdgeGroupID{1},
DeploymentType: portainer.EdgeStackDeploymentKubernetes,
},
QueryString: "method=string",
Method: "string",
ExpectedStatusCode: 500,
},
{
@ -364,7 +359,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
EdgeGroups: []portainer.EdgeGroupID{1},
DeploymentType: portainer.EdgeStackDeploymentCompose,
},
QueryString: "method=string",
Method: "string",
ExpectedStatusCode: 400,
},
{
@ -380,7 +375,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
EdgeGroups: []portainer.EdgeGroupID{1},
DeploymentType: portainer.EdgeStackDeploymentCompose,
},
QueryString: "method=repository",
Method: "repository",
ExpectedStatusCode: 500,
},
}
@ -394,7 +389,7 @@ func TestCreateWithInvalidPayload(t *testing.T) {
r := bytes.NewBuffer(jsonPayload)
// Create EdgeStack
req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("/edge_stacks?%s", tc.QueryString), r)
req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("/edge_stacks/create/%s", tc.Method), r)
if err != nil {
t.Fatal("request error:", err)
}