Skip to content

Commit

Permalink
Vc/firmware set validation attribute (#102)
Browse files Browse the repository at this point in the history
* add firmware_set_validation_facts table

* don't make server-id a foreign key

* client function and api endpoint for firmware validation

* handle potentially wrapped sql errors
  • Loading branch information
DoctorVin authored Aug 21, 2024
1 parent 61ee781 commit f4caeb1
Show file tree
Hide file tree
Showing 16 changed files with 2,581 additions and 55 deletions.
14 changes: 14 additions & 0 deletions db/migrations/00008_firmware_validation_facts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE public.firmware_set_validation_facts(
id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
firmware_set_id UUID NOT NULL REFERENCES public.component_firmware_set(id) ON DELETE CASCADE,
target_server_id UUID NOT NULL,
performed_on TIMESTAMPTZ NOT NULL
)
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
DROP TABLE public.firmware_set_validation_facts
-- +goose StatementEnd
25 changes: 25 additions & 0 deletions internal/dbtools/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ var (
FixtureEventHistoryServer *models.Server
FixtureEventHistoryRelatedID uuid.UUID
FixtureEventHistories []*models.EventHistory

FixtureFWValidationServer *models.Server
FixtureFWValidationSet *models.ComponentFirmwareSet
)

func addFixtures(t *testing.T) error {
Expand Down Expand Up @@ -183,6 +186,10 @@ func addFixtures(t *testing.T) error {
return err
}

if err := setupFWValidationFixtures(ctx, testDB); err != nil {
return err
}

// excluding Chuckles here since that server is deleted
FixtureServers = models.ServerSlice{FixtureNemo, FixtureDory, FixtureMarlin}
FixtureDeletedServers = models.ServerSlice{FixtureChuckles}
Expand Down Expand Up @@ -886,3 +893,21 @@ func setupConfigSet(ctx context.Context, db *sqlx.DB) error {

return nil
}

func setupFWValidationFixtures(ctx context.Context, db *sqlx.DB) error {
FixtureFWValidationServer = &models.Server{
Name: null.StringFrom("firmware-validation"),
FacilityCode: null.StringFrom("tf2"),
}

if err := FixtureFWValidationServer.Insert(ctx, db, boil.Infer()); err != nil {
return errors.Wrap(err, "firmware validation server fixture")
}

FixtureFWValidationSet = &models.ComponentFirmwareSet{Name: "firmware-validation"}
if err := FixtureFWValidationSet.Insert(ctx, db, boil.Infer()); err != nil {
return errors.Wrap(err, "firmware validation set fixture")
}

return nil
}
22 changes: 22 additions & 0 deletions internal/models/boil_suites_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 38 additions & 36 deletions internal/models/boil_table_names.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f4caeb1

Please sign in to comment.