@@ -71,7 +71,7 @@ func TestRepository(t *testing.T) {
7171
7272 // WHEN
7373 comment := "a task log"
74- err = UpdateActiveTL (testDB , tlID , taskID , beginTS , endTS , numSeconds , comment )
74+ err = UpdateActiveTL (testDB , tlID , taskID , beginTS , endTS , numSeconds , & comment )
7575
7676 // THEN
7777 require .NoError (t , err , "failed to update task log" )
@@ -83,7 +83,8 @@ func TestRepository(t *testing.T) {
8383 require .NoError (t , err , "failed to fetch task" )
8484
8585 assert .Equal (t , numSeconds , taskLog .SecsSpent )
86- assert .Equal (t , comment , taskLog .Comment )
86+ require .NotNil (t , taskLog .Comment )
87+ assert .Equal (t , comment , * taskLog .Comment )
8788 assert .Equal (t , numSecondsBefore + numSeconds , taskAfter .SecsSpent )
8889 })
8990
@@ -105,7 +106,7 @@ func TestRepository(t *testing.T) {
105106 numSeconds := 60 * 90
106107 endTS := time .Now ()
107108 beginTS := endTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
108- tlID , err := InsertManualTL (testDB , taskID , beginTS , endTS , comment )
109+ tlID , err := InsertManualTL (testDB , taskID , beginTS , endTS , & comment )
109110
110111 // THEN
111112 require .NoError (t , err , "failed to insert task log" )
@@ -117,10 +118,36 @@ func TestRepository(t *testing.T) {
117118 require .NoError (t , err , "failed to fetch task" )
118119
119120 assert .Equal (t , numSeconds , taskLog .SecsSpent )
120- assert .Equal (t , comment , taskLog .Comment )
121+ require .NotNil (t , taskLog .Comment )
122+ assert .Equal (t , comment , * taskLog .Comment )
121123 assert .Equal (t , numSecondsBefore + numSeconds , taskAfter .SecsSpent )
122124 })
123125
126+ t .Run ("TestInsertManualTL can insert TL with empty comment" , func (t * testing.T ) {
127+ t .Cleanup (func () { cleanupDB (t , testDB ) })
128+
129+ // GIVEN
130+ referenceTS := time .Now ()
131+ seedData := getTestData (referenceTS )
132+ seedDB (t , testDB , seedData )
133+ taskID := 1
134+
135+ // WHEN
136+ numSeconds := 60 * 90
137+ endTS := time .Now ()
138+ beginTS := endTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
139+ tlID , err := InsertManualTL (testDB , taskID , beginTS , endTS , nil )
140+
141+ // THEN
142+ require .NoError (t , err , "failed to insert task log" )
143+
144+ taskLog , err := fetchTLByID (testDB , tlID )
145+ require .NoError (t , err , "failed to fetch task log" )
146+
147+ assert .Equal (t , numSeconds , taskLog .SecsSpent )
148+ assert .Nil (t , taskLog .Comment )
149+ })
150+
124151 t .Run ("TestDeleteTaskLogEntry" , func (t * testing.T ) {
125152 t .Cleanup (func () { cleanupDB (t , testDB ) })
126153
@@ -160,7 +187,8 @@ func TestRepository(t *testing.T) {
160187 numSeconds := 60 * 90
161188 tlEndTS := referenceTS .Add (time .Hour * 2 )
162189 tlBeginTS := tlEndTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
163- _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , taskLogComment )
190+ comment := taskLogComment
191+ _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , & comment )
164192 require .NoError (t , err , "failed to insert task log" )
165193
166194 // WHEN
@@ -185,7 +213,7 @@ func TestRepository(t *testing.T) {
185213 numSeconds := 60 * 90
186214 tlEndTS := referenceTS .Add (time .Hour * 2 )
187215 tlBeginTS := tlEndTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
188- _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , comment )
216+ _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , & comment )
189217 require .NoError (t , err , "failed to insert task log" )
190218
191219 // WHEN
@@ -216,7 +244,8 @@ func TestRepository(t *testing.T) {
216244 numSeconds := 60 * 90
217245 tlEndTS := referenceTS .Add (time .Hour * 2 )
218246 tlBeginTS := tlEndTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
219- _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , taskLogComment )
247+ comment := taskLogComment
248+ _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , & comment )
220249 require .NoError (t , err , "failed to insert task log" )
221250
222251 // WHEN
@@ -248,7 +277,8 @@ func TestRepository(t *testing.T) {
248277 numSeconds := 60 * 90
249278 tlEndTS := referenceTS .Add (time .Hour * 2 )
250279 tlBeginTS := tlEndTS .Add (time .Second * - 1 * time .Duration (numSeconds ))
251- _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , taskLogComment )
280+ comment := taskLogComment
281+ _ , err = InsertManualTL (testDB , taskID , tlBeginTS , tlEndTS , & comment )
252282 require .NoError (t , err , "failed to insert task log" )
253283
254284 // WHEN
@@ -312,30 +342,33 @@ func getTestData(referenceTS time.Time) testData {
312342 },
313343 }
314344
345+ commentTask1TL1 := "task 1 tl 1"
346+ commentTask1TL2 := "task 1 tl 2"
347+ commentTask2TL1 := "task 2 tl 1"
315348 taskLogs := []types.TaskLogEntry {
316349 {
317350 ID : 1 ,
318351 TaskID : 1 ,
319352 BeginTS : ca .Add (time .Hour * 2 ),
320353 EndTS : ca .Add (time .Hour * 4 ),
321354 SecsSpent : 2 * secsInOneHour ,
322- Comment : "task 1 tl 1" ,
355+ Comment : & commentTask1TL1 ,
323356 },
324357 {
325358 ID : 2 ,
326359 TaskID : 1 ,
327360 BeginTS : ca .Add (time .Hour * 6 ),
328361 EndTS : ca .Add (time .Hour * 9 ),
329362 SecsSpent : 3 * secsInOneHour ,
330- Comment : "task 1 tl 2" ,
363+ Comment : & commentTask1TL2 ,
331364 },
332365 {
333366 ID : 3 ,
334367 TaskID : 2 ,
335368 BeginTS : ca .Add (time .Hour * 2 ),
336369 EndTS : ca .Add (time .Hour * 6 ),
337370 SecsSpent : 4 * secsInOneHour ,
338- Comment : "task 2 tl 1" ,
371+ Comment : & commentTask2TL1 ,
339372 },
340373 }
341374
0 commit comments