99 "time"
1010
1111 "gotest.tools/v3/assert"
12+ "gotest.tools/v3/assert/cmp"
1213)
1314
1415const (
@@ -28,11 +29,13 @@ func TestDo(t *testing.T) {
2829 input := strings .NewReader (testEventJSON )
2930 var output bytes.Buffer
3031
32+ ghaBuff := bytes .NewBuffer (nil )
3133 cfg := config {
32- slowThreshold : 200 * time .Millisecond ,
33- modName : testModuleName ,
34- verbose : false ,
35- stream : false ,
34+ slowThreshold : 200 * time .Millisecond ,
35+ modName : testModuleName ,
36+ verbose : false ,
37+ stream : false ,
38+ ghaCommandsOut : ghaBuff ,
3639 }
3740
3841 anyFail , err := do (input , & output , cfg )
@@ -41,18 +44,21 @@ func TestDo(t *testing.T) {
4144
4245 // Non-verbose output should only include the grouped fail events + error annotations
4346 expected := failGroup + timeoutGroup + annotation
44- assert .Equal (t , expected , output .String ())
47+ assert .Check (t , cmp .Equal (expected , output .String ()))
48+ assert .Check (t , cmp .Equal (ghaCommandsOutput , ghaBuff .String ()))
4549 })
4650
4751 t .Run ("verbose=true" , func (t * testing.T ) {
4852 input := strings .NewReader (testEventJSON )
4953 var output bytes.Buffer
5054
55+ ghaBuff := bytes .NewBuffer (nil )
5156 cfg := config {
52- slowThreshold : 200 * time .Millisecond ,
53- modName : testModuleName ,
54- verbose : true ,
55- stream : false ,
57+ slowThreshold : 200 * time .Millisecond ,
58+ modName : testModuleName ,
59+ verbose : true ,
60+ stream : false ,
61+ ghaCommandsOut : ghaBuff ,
5662 }
5763
5864 anyFail , err := do (input , & output , cfg )
@@ -62,17 +68,21 @@ func TestDo(t *testing.T) {
6268 // verbose output should include grouped events for all test results + error annotations
6369 expected := failGroup + passGroup + skipGroup + timeoutGroup + annotation
6470 assert .Equal (t , output .String (), expected )
71+ assert .Check (t , cmp .Equal (expected , output .String ()))
72+ assert .Check (t , cmp .Equal (ghaCommandsOutput , ghaBuff .String ()))
6573 })
6674
6775 t .Run ("stream=true" , func (t * testing.T ) {
6876 input := strings .NewReader (testEventJSON )
6977 var output bytes.Buffer
7078
79+ ghaBuff := bytes .NewBuffer (nil )
7180 cfg := config {
72- slowThreshold : 200 * time .Millisecond ,
73- modName : testModuleName ,
74- verbose : false ,
75- stream : true ,
81+ slowThreshold : 200 * time .Millisecond ,
82+ modName : testModuleName ,
83+ verbose : false ,
84+ stream : true ,
85+ ghaCommandsOut : ghaBuff ,
7686 }
7787
7888 anyFail , err := do (input , & output , cfg )
@@ -81,7 +91,8 @@ func TestDo(t *testing.T) {
8191
8292 // Stream output should include all the raw events + the grouped fail events + the annotation
8393 expected := testEventPassOutput + testEventFailOutput + testEventSkipOutput + testEventTimeoutOutput + testEventPackageOutput + failGroup + timeoutGroup + annotation
84- assert .Equal (t , output .String (), expected )
94+ assert .Check (t , cmp .Equal (expected , output .String ()))
95+ assert .Check (t , cmp .Equal (ghaCommandsOutput , ghaBuff .String ()))
8596 })
8697
8798 t .Run ("summary" , func (t * testing.T ) {
@@ -94,11 +105,13 @@ func TestDo(t *testing.T) {
94105
95106 input := strings .NewReader (testEventJSON )
96107
108+ ghaBuff := bytes .NewBuffer (nil )
97109 cfg := config {
98- slowThreshold : 200 * time .Millisecond ,
99- modName : testModuleName ,
100- verbose : false ,
101- stream : false ,
110+ slowThreshold : 200 * time .Millisecond ,
111+ modName : testModuleName ,
112+ verbose : false ,
113+ stream : false ,
114+ ghaCommandsOut : ghaBuff ,
102115 }
103116
104117 anyFail , err := do (input , io .Discard , cfg )
@@ -125,20 +138,23 @@ some_package: 0.250s
125138
126139`
127140
128- assert .Equal (t , string (output ), expect )
141+ assert .Check (t , cmp .Equal (string (output ), expect ))
142+ assert .Check (t , cmp .Equal (ghaCommandsOutput , ghaBuff .String ()))
129143 })
130144
131145 t .Run ("LogDir" , func (t * testing.T ) {
132146 input := strings .NewReader (testEventJSON )
133147 var output bytes.Buffer
134148
135149 logDir := t .TempDir ()
150+ ghaBuff := bytes .NewBuffer (nil )
136151 cfg := config {
137- slowThreshold : 500 ,
138- modName : "github.com/Azure/dalec/cmd/test2json2gha" ,
139- verbose : false ,
140- stream : false ,
141- logDir : logDir ,
152+ slowThreshold : 500 ,
153+ modName : "github.com/Azure/dalec/cmd/test2json2gha" ,
154+ verbose : false ,
155+ stream : false ,
156+ logDir : logDir ,
157+ ghaCommandsOut : ghaBuff ,
142158 }
143159
144160 anyFail , err := do (input , & output , cfg )
@@ -148,6 +164,7 @@ some_package: 0.250s
148164 // Validate that logs are written to the specified directory
149165 entries , err := os .ReadDir (logDir )
150166 assert .NilError (t , err )
151- assert .Assert (t , len (entries ) > 0 , "expected log files to be written to the log directory" )
167+ assert .Check (t , len (entries ) > 0 , "expected log files to be written to the log directory" )
168+ assert .Check (t , cmp .Equal (ghaCommandsOutput , ghaBuff .String ()))
152169 })
153170}
0 commit comments