@@ -112,6 +112,43 @@ var _ = Describe("GormSpecRunRepository", func() {
112112 })
113113 })
114114
115+ Context ("when the spec run has only a FailureMessage (status \" failed\" )" , func () {
116+ It ("should persist FailureMessage into the error_message column" , func () {
117+ endTime := time .Now ().Add (time .Second )
118+ failedSpec := & domain.SpecRun {
119+ SuiteRunID : 1 ,
120+ Name : "test-spec-failed" ,
121+ Status : "failed" ,
122+ StartTime : time .Now (),
123+ EndTime : & endTime ,
124+ Duration : time .Second ,
125+ FailureMessage : "expected 2 to equal 3" ,
126+ }
127+
128+ mock .ExpectBegin ()
129+ mock .ExpectQuery (regexp .QuoteMeta (`INSERT INTO "spec_runs"` )).
130+ WithArgs (
131+ AnyTime {}, AnyTime {}, nil ,
132+ failedSpec .SuiteRunID ,
133+ failedSpec .Name ,
134+ failedSpec .Status ,
135+ AnyTime {}, AnyTime {},
136+ int64 (1000 ),
137+ failedSpec .FailureMessage ,
138+ failedSpec .StackTrace ,
139+ failedSpec .RetryCount ,
140+ failedSpec .IsFlaky ,
141+ ).
142+ WillReturnRows (sqlmock .NewRows ([]string {"id" }).AddRow (456 ))
143+ mock .ExpectCommit ()
144+
145+ err := repository .Create (ctx , failedSpec )
146+
147+ Expect (err ).NotTo (HaveOccurred ())
148+ Expect (failedSpec .ID ).To (Equal (uint (456 )))
149+ })
150+ })
151+
115152 Context ("when creation fails" , func () {
116153 It ("should return an error" , func () {
117154 mock .ExpectBegin ()
@@ -180,6 +217,40 @@ var _ = Describe("GormSpecRunRepository", func() {
180217 })
181218 })
182219
220+ Context ("when the batch has a spec run with only a FailureMessage" , func () {
221+ It ("should persist FailureMessage into the error_message column" , func () {
222+ now := time .Now ()
223+ end := now .Add (time .Second )
224+
225+ specRuns := []* domain.SpecRun {
226+ {
227+ SuiteRunID : 1 ,
228+ Name : "test-spec-failed" ,
229+ Status : "failed" ,
230+ StartTime : now ,
231+ EndTime : & end ,
232+ Duration : time .Second ,
233+ FailureMessage : "expected 2 to equal 3" ,
234+ },
235+ }
236+
237+ mock .ExpectBegin ()
238+ mock .ExpectQuery (regexp .QuoteMeta (`INSERT INTO "spec_runs"` )).
239+ WithArgs (
240+ AnyTime {}, AnyTime {}, nil ,
241+ uint (1 ), "test-spec-failed" , "failed" , AnyTime {}, AnyTime {}, int64 (1000 ),
242+ "expected 2 to equal 3" , "" , 0 , false ,
243+ ).
244+ WillReturnRows (sqlmock .NewRows ([]string {"id" }).AddRow (1 ))
245+ mock .ExpectCommit ()
246+
247+ err := repository .CreateBatch (ctx , specRuns )
248+
249+ Expect (err ).NotTo (HaveOccurred ())
250+ Expect (specRuns [0 ].ID ).To (Equal (uint (1 )))
251+ })
252+ })
253+
183254 Context ("when batch creation fails" , func () {
184255 It ("should return an error" , func () {
185256 now := time .Now ()
0 commit comments