Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint to list events from a test run (#2276)
add endpoint to list events from a test run
- Loading branch information
1 parent
132814b
commit b907493
Showing
10 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package mappings | ||
|
||
import ( | ||
"github.com/kubeshop/tracetest/server/model" | ||
"github.com/kubeshop/tracetest/server/openapi" | ||
) | ||
|
||
func (m OpenAPI) TestRunEvents(in []model.TestRunEvent) []openapi.TestRunEvent { | ||
out := make([]openapi.TestRunEvent, 0, len(in)) | ||
for _, event := range in { | ||
out = append(out, m.TestRunEvent(event)) | ||
} | ||
|
||
return out | ||
} | ||
|
||
func (m OpenAPI) TestRunEvent(in model.TestRunEvent) openapi.TestRunEvent { | ||
return openapi.TestRunEvent{ | ||
Type: in.Type, | ||
Stage: string(in.Stage), | ||
Description: in.Description, | ||
CreatedAt: in.CreatedAt, | ||
TestId: string(in.TestID), | ||
RunId: int32(in.RunID), | ||
DataStoreConnection: m.ConnectionTestResult(in.DataStoreConnection), | ||
Polling: m.PollingInfo(in.Polling), | ||
Outputs: m.OutputsInfo(in.Outputs), | ||
} | ||
} | ||
|
||
func (m OpenAPI) PollingInfo(in model.PollingInfo) openapi.PollingInfo { | ||
return openapi.PollingInfo{ | ||
Type: string(in.Type), | ||
ReasonNextIteration: in.ReasonNextIteration, | ||
IsComplete: in.IsComplete, | ||
Periodic: m.PeriodicPollingInfo(in.Periodic), | ||
} | ||
} | ||
|
||
func (m OpenAPI) PeriodicPollingInfo(in *model.PeriodicPollingConfig) openapi.PollingInfoPeriodic { | ||
if in == nil { | ||
return openapi.PollingInfoPeriodic{} | ||
} | ||
|
||
return openapi.PollingInfoPeriodic{ | ||
NumberSpans: int32(in.NumberSpans), | ||
NumberIterations: int32(in.NumberIterations), | ||
} | ||
} | ||
|
||
func (m OpenAPI) OutputsInfo(in []model.OutputInfo) []openapi.OutputInfo { | ||
out := make([]openapi.OutputInfo, 0, len(in)) | ||
for _, output := range in { | ||
newOutput := openapi.OutputInfo{ | ||
LogLevel: string(output.LogLevel), | ||
Message: output.Message, | ||
OutputName: output.OutputName, | ||
} | ||
|
||
out = append(out, newOutput) | ||
} | ||
|
||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters