Skip to content

Commit

Permalink
revert: use shorter funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
s1ntaxe770r committed Jul 29, 2024
1 parent 0294162 commit 212e369
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
31 changes: 0 additions & 31 deletions tests/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,6 @@ func createOrg() (string, string, error) {
return resp.Id, resp.Name, nil
}

func createProject(orgid string) (string, string, error) {

client := qernalClient()

projectbody := *openapi_chaos_client.NewProjectBody(orgid, uuid.NewString())

resp, r, err := client.ProjectsAPI.ProjectsCreate(context.Background()).ProjectBody(projectbody).Execute()

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ProjectsAPI.ProjectsCreate`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)

return "", "", err
}

return resp.Id, resp.Name, nil
}

func deleteOrg(orgid string) {
client := qernalClient()
_, r, err := client.OrganisationsAPI.OrganisationsDelete(context.Background(), orgid).Execute()
Expand Down Expand Up @@ -151,19 +133,6 @@ func getDefaultHost(projid string) (string, error) {
return "", errors.New("no default host on project")
}

func deleteProject(projectid string) {
client := qernalClient()

_, r, err := client.ProjectsAPI.ProjectsDelete(context.Background(), projectid).Execute()

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ProjectsAPI.ProjectsDelete`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)

}

}

func cleanupTerraformFiles(modulePath string) error {

// List of files/directories to remove
Expand Down
4 changes: 2 additions & 2 deletions tests/qernal_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestProjectDataSource(t *testing.T) {
t.Fatal("Failed to create org")
}

projectId, projectName, err := createProject(orgId)
projectId, projectName, err := createProj(orgId)
if err != nil {
t.Fatal("Failed to create test org")
}
Expand All @@ -85,7 +85,7 @@ func TestProjectDataSource(t *testing.T) {
},
})

defer deleteProject(projectId)
defer deleteProj(projectId)
defer deleteOrg(orgId)

defer terraform.Destroy(t, terraformOptions)
Expand Down
4 changes: 2 additions & 2 deletions tests/qernal_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestEnvironmentSecret(t *testing.T) {
t.Fatal("Failed to create org")
}

projectId, _, err := createProject(orgId)
projectId, _, err := createProj(orgId)
if err != nil {
t.Fatal("Failed to create project")
}
Expand Down Expand Up @@ -52,7 +52,7 @@ func TestEnvironmentSecret(t *testing.T) {
},
})

defer deleteProject(projectId)
defer deleteProj(projectId)
defer deleteOrg(orgId)
defer terraform.Destroy(t, terraformOptions)

Expand Down

0 comments on commit 212e369

Please sign in to comment.