Skip to content

Commit

Permalink
api/router_server_components_test: fix test case for component attrib…
Browse files Browse the repository at this point in the history
…utes update

Update an existing fixture component attribute as a test case - this was
incorrectly adding a component attribute instead of updating it.
  • Loading branch information
joelrebel committed Dec 20, 2022
1 parent 05fdae4 commit 284ae49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
30 changes: 20 additions & 10 deletions internal/dbtools/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ var (
// Server Component Types
FixtureFinType *models.ServerComponentType

FixtureNemo *models.Server
FixtureNemoMetadata *models.Attribute
FixtureNemoOtherdata *models.Attribute
FixtureNemoLeftFin *models.ServerComponent
FixtureNemoRightFin *models.ServerComponent
FixtureNemoLeftFinVersioned *models.VersionedAttribute
FixtureNemoVersionedNew *models.VersionedAttribute
FixtureNemoVersionedOld *models.VersionedAttribute
FixtureNemoVersionedV2 *models.VersionedAttribute
FixtureNemoBMCSecret *models.ServerCredential
FixtureNemo *models.Server
FixtureNemoMetadata *models.Attribute
FixtureNemoOtherdata *models.Attribute
FixtureNemoLeftFin *models.ServerComponent
FixtureNemoRightFin *models.ServerComponent
FixtureNemoLeftFinVersioned *models.VersionedAttribute
FixtureNemoVersionedNew *models.VersionedAttribute
FixtureNemoVersionedOld *models.VersionedAttribute
FixtureNemoVersionedV2 *models.VersionedAttribute
FixtureNemoBMCSecret *models.ServerCredential
FixtureNemoRightFinOtherData *models.Attribute

FixtureDory *models.Server
FixtureDoryMetadata *models.Attribute
Expand Down Expand Up @@ -204,6 +205,15 @@ func setupNemo(ctx context.Context, db *sqlx.DB, t *testing.T) error {
return err
}

FixtureNemoRightFinOtherData = &models.Attribute{
Namespace: FixtureNamespaceOtherdata,
Data: types.JSON([]byte(`{"twitchy": true}`)),
}

if err := FixtureNemoRightFin.AddAttributes(ctx, db, true, FixtureNemoRightFinOtherData); err != nil {
return err
}

FixtureNemoLeftFinVersioned = &models.VersionedAttribute{
Namespace: FixtureNamespaceVersioned,
Data: types.JSON([]byte(`{"something": "cool"}`)),
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1/router_server_components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) {
"component update on attributes",
serverFixture.UUID,
componentFixtureCopy(),
change{attributes: []byte(`{"status":"OK"}`)},
change{attributes: []byte(`{"twitches":"false"}`)},
"",
"",
},
Expand Down Expand Up @@ -689,7 +689,7 @@ func TestIntegrationServerUpdateComponents(t *testing.T) {
if len(tt.change.attributes) > 0 {
tt.components[0].Attributes = []serverservice.Attributes{
{
Namespace: "hollow.attributes",
Namespace: dbtools.FixtureNamespaceOtherdata,
Data: tt.change.attributes,
},
}
Expand Down

0 comments on commit 284ae49

Please sign in to comment.