Skip to content

Commit

Permalink
Fix testreport cases pb conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
cluttrdev committed Jan 26, 2024
1 parent 5099d6c commit 5e0c3f2
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions internal/models/testreport.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,19 @@ func ConvertTestReport(pipelineID int64, report *gitlab.PipelineTestReport) (*pb
cases := make([]*pb.TestCase, 0, len(testsuite.TestCases))
for j, testcase := range testsuite.TestCases {
cases = append(cases, &pb.TestCase{
Id: testCaseID(testsuiteID, j),
TestsuiteId: testsuiteID,
TestreportId: testreport.Id,
PipelineId: pipelineID,
Status: testcase.Status,
Name: testcase.Name,
Classname: testcase.Classname,
File: testcase.File,
ExecutionTime: testcase.ExecutionTime,
SystemOutput: fmt.Sprint(testcase.SystemOutput),
StackTrace: testcase.StackTrace,
AttachmentUrl: testcase.AttachmentURL,
RecentFailures: &pb.TestCase_RecentFailures{
Count: int64(testcase.RecentFailures.Count),
BaseBranch: testcase.RecentFailures.BaseBranch,
},
Id: testCaseID(testsuiteID, j),
TestsuiteId: testsuiteID,
TestreportId: testreport.Id,
PipelineId: pipelineID,
Status: testcase.Status,
Name: testcase.Name,
Classname: testcase.Classname,
File: testcase.File,
ExecutionTime: testcase.ExecutionTime,
SystemOutput: fmt.Sprint(testcase.SystemOutput),
StackTrace: testcase.StackTrace,
AttachmentUrl: testcase.AttachmentURL,
RecentFailures: convertTestCaseRecentFailures(testcase.RecentFailures),
})
}
testcases = append(testcases, cases...)
Expand All @@ -64,6 +61,15 @@ func ConvertTestReport(pipelineID int64, report *gitlab.PipelineTestReport) (*pb
return testreport, testsuites, testcases
}

func convertTestCaseRecentFailures(f *gitlab.RecentFailures) *pb.TestCase_RecentFailures {
var r pb.TestCase_RecentFailures
if f != nil {
r.Count = int64(f.Count)
r.BaseBranch = f.BaseBranch
}
return &r
}

func testReportID(pipelineID int64) string {
return fmt.Sprint(pipelineID)
}
Expand Down

0 comments on commit 5e0c3f2

Please sign in to comment.