diff --git a/api/testEvents.yaml b/api/testEvents.yaml index f60c38a2ef..f21dd51d06 100644 --- a/api/testEvents.yaml +++ b/api/testEvents.yaml @@ -12,6 +12,8 @@ components: - trigger - trace - test + title: + type: string description: type: string createdAt: diff --git a/cli/openapi/model_test_run_event.go b/cli/openapi/model_test_run_event.go index 1b42282f48..1fbcd708c3 100644 --- a/cli/openapi/model_test_run_event.go +++ b/cli/openapi/model_test_run_event.go @@ -22,6 +22,7 @@ var _ MappedNullable = &TestRunEvent{} type TestRunEvent struct { Type *string `json:"type,omitempty"` Stage *string `json:"stage,omitempty"` + Title *string `json:"title,omitempty"` Description *string `json:"description,omitempty"` CreatedAt *time.Time `json:"createdAt,omitempty"` TestId *string `json:"testId,omitempty"` @@ -112,6 +113,38 @@ func (o *TestRunEvent) SetStage(v string) { o.Stage = &v } +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *TestRunEvent) GetTitle() string { + if o == nil || isNil(o.Title) { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TestRunEvent) GetTitleOk() (*string, bool) { + if o == nil || isNil(o.Title) { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *TestRunEvent) HasTitle() bool { + if o != nil && !isNil(o.Title) { + return true + } + + return false +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *TestRunEvent) SetTitle(v string) { + o.Title = &v +} + // GetDescription returns the Description field value if set, zero value otherwise. func (o *TestRunEvent) GetDescription() string { if o == nil || isNil(o.Description) { @@ -352,6 +385,9 @@ func (o TestRunEvent) ToMap() (map[string]interface{}, error) { if !isNil(o.Stage) { toSerialize["stage"] = o.Stage } + if !isNil(o.Title) { + toSerialize["title"] = o.Title + } if !isNil(o.Description) { toSerialize["description"] = o.Description } diff --git a/server/migrations/24_add_test_run_events_title.down.sql b/server/migrations/24_add_test_run_events_title.down.sql new file mode 100644 index 0000000000..286f8fdca9 --- /dev/null +++ b/server/migrations/24_add_test_run_events_title.down.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE "test_run_events" DROP COLUMN title; + +COMMIT; diff --git a/server/migrations/24_add_test_run_events_title.up.sql b/server/migrations/24_add_test_run_events_title.up.sql new file mode 100644 index 0000000000..390c4cbf80 --- /dev/null +++ b/server/migrations/24_add_test_run_events_title.up.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE "test_run_events" ADD COLUMN "title" varchar not null; + +COMMIT; diff --git a/server/model/test_run_event.go b/server/model/test_run_event.go index 2981281462..96c8d0fef4 100644 --- a/server/model/test_run_event.go +++ b/server/model/test_run_event.go @@ -44,6 +44,7 @@ type TestRunEvent struct { ID int64 Type string Stage TestRunEventStage + Title string Description string CreatedAt time.Time TestID id.ID diff --git a/server/openapi/model_test_run_event.go b/server/openapi/model_test_run_event.go index 7eda1a0e80..124445e2ce 100644 --- a/server/openapi/model_test_run_event.go +++ b/server/openapi/model_test_run_event.go @@ -18,6 +18,8 @@ type TestRunEvent struct { Stage string `json:"stage,omitempty"` + Title string `json:"title,omitempty"` + Description string `json:"description,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` diff --git a/server/testdb/test_run_event.go b/server/testdb/test_run_event.go index b2330939a6..35c9ac6ba4 100644 --- a/server/testdb/test_run_event.go +++ b/server/testdb/test_run_event.go @@ -18,6 +18,7 @@ const insertTestRunEventQuery = ` "run_id", "type", "stage", + "title", "description", "created_at", "data_store_connection", @@ -28,11 +29,12 @@ const insertTestRunEventQuery = ` $2, -- run_id $3, -- type $4, -- stage - $5, -- description - $6, -- created_at - $7, -- data_store_connection - $8, -- polling - $9 -- outputs + $5, -- title + $6, -- description + $7, -- created_at + $8, -- data_store_connection + $9, -- polling + $10 -- outputs ) RETURNING "id" ` @@ -64,6 +66,7 @@ func (td *postgresDB) CreateTestRunEvent(ctx context.Context, event model.TestRu event.RunID, event.Type, event.Stage, + event.Title, event.Description, event.CreatedAt, dataStoreConnectionJSON, @@ -85,6 +88,7 @@ const getTestRunEventsQuery = ` "run_id", "type", "stage", + "title", "description", "created_at", "data_store_connection", @@ -123,6 +127,7 @@ func readTestRunEventFromRows(rows *sql.Rows) (model.TestRunEvent, error) { &event.RunID, &event.Type, &event.Stage, + &event.Title, &event.Description, &event.CreatedAt, &dataStoreConnectionBytes, diff --git a/server/testdb/test_run_event_test.go b/server/testdb/test_run_event_test.go index ae53a021eb..54e53a0d1c 100644 --- a/server/testdb/test_run_event_test.go +++ b/server/testdb/test_run_event_test.go @@ -19,10 +19,10 @@ func TestRunEvents(t *testing.T) { run2 := createRun(t, db, test1) events := []model.TestRunEvent{ - {TestID: test1.ID, RunID: run1.ID, Type: "EVENT_1", Stage: model.StageTrigger, Description: "This happened"}, - {TestID: test1.ID, RunID: run1.ID, Type: "EVENT_2", Stage: model.StageTrigger, Description: "That happened now"}, + {TestID: test1.ID, RunID: run1.ID, Type: "EVENT_1", Stage: model.StageTrigger, Title: "OP 1", Description: "This happened"}, + {TestID: test1.ID, RunID: run1.ID, Type: "EVENT_2", Stage: model.StageTrigger, Title: "OP 2", Description: "That happened now"}, - {TestID: test1.ID, RunID: run2.ID, Type: "EVENT_1", Stage: model.StageTrigger, Description: "That happened", DataStoreConnection: model.ConnectionResult{ + {TestID: test1.ID, RunID: run2.ID, Type: "EVENT_1", Stage: model.StageTrigger, Title: "OP 1", Description: "That happened", DataStoreConnection: model.ConnectionResult{ PortCheck: model.ConnectionTestStep{ Passed: true, Status: model.StatusPassed, @@ -30,14 +30,14 @@ func TestRunEvents(t *testing.T) { Error: nil, }, }}, - {TestID: test1.ID, RunID: run2.ID, Type: "EVENT_2_FAILED", Stage: model.StageTrigger, Description: "That happened, but failed", Polling: model.PollingInfo{ + {TestID: test1.ID, RunID: run2.ID, Type: "EVENT_2_FAILED", Stage: model.StageTrigger, Title: "OP 2", Description: "That happened, but failed", Polling: model.PollingInfo{ Type: model.PollingTypePeriodic, Periodic: &model.PeriodicPollingConfig{ NumberSpans: 3, NumberIterations: 1, }, }}, - {TestID: test1.ID, RunID: run2.ID, Type: "ANOTHER_EVENT", Stage: model.StageTrigger, Description: "Clean up after error", Outputs: []model.OutputInfo{ + {TestID: test1.ID, RunID: run2.ID, Type: "ANOTHER_EVENT", Stage: model.StageTrigger, Title: "OP 3", Description: "Clean up after error", Outputs: []model.OutputInfo{ {LogLevel: model.LogLevelWarn, Message: "INVALID SYNTAX", OutputName: "my_output"}, }}, } @@ -52,6 +52,8 @@ func TestRunEvents(t *testing.T) { assert.Len(t, events, 2) assert.LessOrEqual(t, events[0].CreatedAt, events[1].CreatedAt) + assert.Equal(t, "OP 1", events[0].Title) + assert.Equal(t, "OP 2", events[1].Title) eventsFromRun2, err := db.GetTestRunEvents(context.Background(), test1.ID, run2.ID) require.NoError(t, err) @@ -60,7 +62,7 @@ func TestRunEvents(t *testing.T) { assert.LessOrEqual(t, eventsFromRun2[0].CreatedAt, eventsFromRun2[1].CreatedAt) assert.LessOrEqual(t, eventsFromRun2[1].CreatedAt, eventsFromRun2[2].CreatedAt) - // assert eevents from run 2 have fields that were stored as JSON + // assert events from run 2 have fields that were stored as JSON // data store connection assert.Equal(t, true, eventsFromRun2[0].DataStoreConnection.PortCheck.Passed) assert.Equal(t, model.StatusPassed, eventsFromRun2[0].DataStoreConnection.PortCheck.Status) diff --git a/web/src/types/Generated.types.ts b/web/src/types/Generated.types.ts index 0d66887203..c08e9a3faa 100644 --- a/web/src/types/Generated.types.ts +++ b/web/src/types/Generated.types.ts @@ -1797,6 +1797,7 @@ export interface external { type?: string; /** @enum {string} */ stage?: "trigger" | "trace" | "test"; + title?: string; description?: string; /** Format: date-time */ createdAt?: string;