Skip to content

Commit

Permalink
fix: transaction ws notifications (#1525)
Browse files Browse the repository at this point in the history
* include trigger and assertion information on notification

* fix result notification
  • Loading branch information
mathnogueira committed Nov 17, 2022
1 parent 06d1fd1 commit 744eda9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions server/executor/transaction_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func createStepRun(testRun model.Run) model.TransactionStepRun {
return model.TransactionStepRun{
ID: testRun.ID,
TestID: testRun.TestID,
Result: *testRun.Results,
State: testRun.State,
Environment: testRun.Environment,
Outputs: testRun.Outputs,
Expand Down
4 changes: 2 additions & 2 deletions server/http/mappings/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ func (m OpenAPI) TransactionRun(in model.TransactionRun) openapi.TransactionRun
runs := make([]openapi.TestRun, 0, len(in.StepRuns))

for _, step := range in.Steps {
steps = append(steps, m.Test(model.Test{ID: step.ID, Name: step.Name}))
steps = append(steps, m.Test(model.Test{ID: step.ID, Name: step.Name, ServiceUnderTest: step.Trigger}))
}

for _, run := range in.StepRuns {
runs = append(runs, m.Run(&model.Run{ID: run.ID, TestID: run.TestID, State: run.State}))
runs = append(runs, m.Run(&model.Run{ID: run.ID, TestID: run.TestID, State: run.State, Results: &run.Result}))
}

return openapi.TransactionRun{
Expand Down
3 changes: 1 addition & 2 deletions server/http/websocket/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ func (e subscribeCommandExecutor) ResourceUpdatedEvent(resource interface{}) Eve
case model.TransactionRun:
mapped = e.mappers.Out.TransactionRun(v)
case *model.TransactionRun:
var value model.TransactionRun = *v
mapped = e.mappers.Out.TransactionRun(value)
mapped = e.mappers.Out.TransactionRun(*v)
default:
fmt.Printf("type %T mapping not supported\n", v)
mapped = v
Expand Down
12 changes: 7 additions & 5 deletions server/model/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ type (
TransactionRunState string

TransactionStep struct {
ID id.ID
Name string
ID id.ID
Name string
Trigger Trigger
}

TransactionStepRun struct {
ID int
TestID id.ID
State RunState
Result RunResults
Environment Environment
Outputs OrderedMap[string, string]
}
Expand Down Expand Up @@ -74,18 +76,18 @@ func (t Transaction) HasID() bool {
}

func NewTransactionRun(transaction Transaction) TransactionRun {
testIds := make([]TransactionStep, 0, len(transaction.Steps))
tests := make([]TransactionStep, 0, len(transaction.Steps))

for _, test := range transaction.Steps {
testIds = append(testIds, TransactionStep{ID: test.ID, Name: test.Name})
tests = append(tests, TransactionStep{ID: test.ID, Name: test.Name, Trigger: test.ServiceUnderTest})
}

return TransactionRun{
TransactionID: transaction.ID,
TransactionVersion: transaction.Version,
CreatedAt: time.Now(),
State: TransactionRunStateCreated,
Steps: testIds,
Steps: tests,
StepRuns: make([]TransactionStepRun, 0, len(transaction.Steps)),
CurrentTest: 0,
}
Expand Down

0 comments on commit 744eda9

Please sign in to comment.