Skip to content

Commit

Permalink
tests: use unique application name
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Apr 5, 2024
1 parent ec4d780 commit 7347565
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions test/c8y_test/applicationVersions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,8 @@ func TestApplicationVersionsService_CRUD_Extension(t *testing.T) {
app, err := client.UIExtension.NewUIExtensionFromFile(file.Name())
testingutils.Ok(t, err)

// Delete application if it already exists
appCol, _, err := client.UIExtension.GetExtensions(
context.Background(),
&c8y.ExtensionOptions{
Name: app.Name,
PaginationOptions: *c8y.NewPaginationOptions(10),
},
)
testingutils.Ok(t, err)
if len(appCol.Applications) > 0 {
for _, app := range appCol.Applications {
_, tErr := client.Application.Delete(context.Background(), app.ID)
testingutils.Ok(t, tErr)
}
}
// Use a unique name
app.Name = testingutils.RandomString(12)

//
// Create
Expand All @@ -153,6 +140,12 @@ func TestApplicationVersionsService_CRUD_Extension(t *testing.T) {
},
})

t.Cleanup(func() {
// Don't check if it failed or not, as the test will also delete the application
// but this cleanup is done just in case the test fails earlier
client.Application.Delete(context.Background(), appVersion.Application.ID)
})

testingutils.Ok(t, err)
testingutils.Assert(t, http.StatusCreated == resp.StatusCode() || http.StatusOK == resp.StatusCode(), "Status code is ok")
testingutils.Equals(t, appVersion.Version, app.ManifestFile.Version)
Expand Down

0 comments on commit 7347565

Please sign in to comment.