Skip to content

Commit

Permalink
feat: detect pipeline with status success-with-warnings (#878)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Boussuge <[email protected]>
  • Loading branch information
seyguai and nicolas-boussuge-fintech authored Jan 14, 2025
1 parent 1c27536 commit e6cc3e6
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/schemas/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewPipeline(ctx context.Context, gp goGitlab.Pipeline) Pipeline {
DurationSeconds: float64(gp.Duration),
QueuedDurationSeconds: float64(gp.QueuedDuration),
Source: gp.Source,
Status: gp.Status,
Status: gp.DetailedStatus.Group,
}
}

Expand Down
87 changes: 68 additions & 19 deletions pkg/schemas/pipelines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,78 @@ func TestNewPipeline(t *testing.T) {
startedAt := time.Date(2020, 10, 1, 13, 5, 10, 0, time.UTC)
updatedAt := time.Date(2020, 10, 1, 13, 5, 50, 0, time.UTC)

gitlabPipeline := goGitlab.Pipeline{
ID: 21,
Coverage: "25.6",
CreatedAt: &createdAt,
StartedAt: &startedAt,
UpdatedAt: &updatedAt,
Duration: 15,
QueuedDuration: 5,
Source: "schedule",
Status: "running",
testCases := []struct {
status string
detailedStatus goGitlab.DetailedStatus
expectedStatus string
}{
{
"running",
goGitlab.DetailedStatus{
Text: "Running",
Label: "running",
Group: "running",
},
"running",
},
{
"success",
goGitlab.DetailedStatus{
Text: "Passed",
Label: "passed",
Group: "success",
},
"success",
},
{
"canceled",
goGitlab.DetailedStatus{
Text: "Canceled",
Label: "canceled",
Group: "canceled",
},
"canceled",
},
{
"success",
goGitlab.DetailedStatus{
Text: "Warning",
Label: "passed with warnings",
Group: "success-with-warnings",
},
"success-with-warnings",
},
}

expectedPipeline := Pipeline{
ID: 21,
Coverage: 25.6,
Timestamp: 1.60155755e+09,
DurationSeconds: 15,
QueuedDurationSeconds: 5,
Source: "schedule",
Status: "running",
for _, tc := range testCases {
t.Run(tc.status, func(t *testing.T) {
gitlabPipeline := goGitlab.Pipeline{
ID: 21,
Coverage: "25.6",
CreatedAt: &createdAt,
StartedAt: &startedAt,
UpdatedAt: &updatedAt,
Duration: 15,
QueuedDuration: 5,
Source: "schedule",
Status: tc.status,
DetailedStatus: &tc.detailedStatus,
}

expectedPipeline := Pipeline{
ID: 21,
Coverage: 25.6,
Timestamp: 1.60155755e+09,
DurationSeconds: 15,
QueuedDurationSeconds: 5,
Source: "schedule",
Status: tc.expectedStatus,
}

assert.Equal(t, expectedPipeline, NewPipeline(context.Background(), gitlabPipeline))
})
}

assert.Equal(t, expectedPipeline, NewPipeline(context.Background(), gitlabPipeline))
}

Check failure on line 89 in pkg/schemas/pipelines_test.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-24.04)

unnecessary trailing newline (whitespace)

func TestNewTestReport(t *testing.T) {
Expand Down

0 comments on commit e6cc3e6

Please sign in to comment.