|
| 1 | +package reporter_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "bytes" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/ctrf-io/go-ctrf-json-reporter/ctrf" |
| 8 | + "github.com/ctrf-io/go-ctrf-json-reporter/reporter" |
| 9 | + "github.com/stretchr/testify/assert" |
| 10 | +) |
| 11 | + |
| 12 | +func Test_Enrich_Reporter(t *testing.T) { |
| 13 | + expected := &ctrf.Report{Results: &ctrf.Results{Tests: []*ctrf.TestResult{ |
| 14 | + { |
| 15 | + Name: "Test_Enrich_Reporter", |
| 16 | + Status: "passed", |
| 17 | + Suite: "github.com/ctrf-io/go-ctrf-json-reporter/reporter", |
| 18 | + Filepath: "reporter_test.go", |
| 19 | + }, |
| 20 | + }}} |
| 21 | + input := `{"Time":"2025-03-02T01:08:01.832222033+01:00","Action":"start","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter"} |
| 22 | +{"Time":"2025-03-02T01:08:01.832309292+01:00","Action":"run","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Test":"Test_Enrich_Reporter"} |
| 23 | +{"Time":"2025-03-02T01:08:01.832321979+01:00","Action":"output","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Test":"Test_Enrich_Reporter","Output":"=== RUN Test_Enrich_Reporter\n"} |
| 24 | +{"Time":"2025-03-02T01:08:01.832333869+01:00","Action":"output","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Test":"Test_Enrich_Reporter","Output":"--- PASS: Test_Enrich_Reporter (0.00s)\n"} |
| 25 | +{"Time":"2025-03-02T01:08:01.832339962+01:00","Action":"pass","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Test":"Test_Enrich_Reporter","Elapsed":0} |
| 26 | +{"Time":"2025-03-02T01:08:01.832347177+01:00","Action":"output","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Output":"PASS\n"} |
| 27 | +{"Time":"2025-03-02T01:08:01.83235318+01:00","Action":"output","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Output":"ok \tgithub.com/ctrf-io/go-ctrf-json-reporter/reporter\t(cached)\n"} |
| 28 | +{"Time":"2025-03-02T01:08:01.832359242+01:00","Action":"pass","Package":"github.com/ctrf-io/go-ctrf-json-reporter/reporter","Elapsed":0}` |
| 29 | + |
| 30 | + actual, err := reporter.ParseTestResults(bytes.NewBufferString(input), false, &ctrf.Environment{}) |
| 31 | + |
| 32 | + assert.Nil(t, err) |
| 33 | + assert.Equal(t, expected.Results.Tests, actual.Results.Tests) |
| 34 | +} |
0 commit comments