Skip to content

Commit 295d12f

Browse files
committed
fix: unit tests
1 parent 5fd78be commit 295d12f

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

pkg/cmd/time-entry/split/split_test.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818

1919
func TestNewCmdSplitShouldFail(t *testing.T) {
2020
w := dto.Workspace{ID: "w"}
21-
start, _ := timehlp.ConvertToTime("2024-06-02 08:15")
22-
end, _ := timehlp.ConvertToTime("2024-06-02 12:15")
21+
start, _ := timehlp.ConvertToTime("08:15")
22+
end, _ := timehlp.ConvertToTime("12:15")
2323
te := dto.TimeEntryImpl{
2424
WorkspaceID: w.ID,
2525
ID: "timeentryid",
@@ -106,13 +106,13 @@ func TestNewCmdSplitShouldFail(t *testing.T) {
106106
name: "split must be after the time entry start",
107107
f: findTT,
108108
args: []string{te.ID, "7:00"},
109-
err: "time splits must be after 2024-06-02 08:15",
109+
err: "time splits must be after .* 08:15",
110110
},
111111
{
112112
name: "split must be before the time entry ends",
113113
f: findTT,
114114
args: []string{te.ID, "18:00"},
115-
err: "time splits must be before 2024-06-02 12:15",
115+
err: "time splits must be before .* 12:15",
116116
},
117117
}
118118

@@ -145,7 +145,7 @@ func TestNewCmdSplitShouldFail(t *testing.T) {
145145

146146
func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
147147
w := dto.Workspace{ID: "w"}
148-
start, _ := timehlp.ConvertToTime("2024-06-02 08:00")
148+
start, _ := timehlp.ConvertToTime("08:00")
149149
te := dto.TimeEntryImpl{
150150
WorkspaceID: w.ID,
151151
ID: "timeentryid",
@@ -229,7 +229,7 @@ func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
229229
name: "split in two",
230230
args: []string{te.ID, "8:30"},
231231
f: func(t *testing.T) cmdutil.Factory {
232-
s, _ := timehlp.ConvertToTime("2024-06-02 08:30")
232+
s, _ := timehlp.ConvertToTime("08:30")
233233
f, c := getAndUpdate(t, te, s)
234234

235235
create(c, "123", util.TimeEntryDTO{
@@ -249,10 +249,10 @@ func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
249249
name: "split in three",
250250
args: []string{te.ID, "08:20", "8:30"},
251251
f: func(t *testing.T) cmdutil.Factory {
252-
s, _ := timehlp.ConvertToTime("2024-06-02 08:20")
252+
s, _ := timehlp.ConvertToTime("08:20")
253253
f, c := getAndUpdate(t, te, s)
254254

255-
e, _ := timehlp.ConvertToTime("2024-06-02 08:30")
255+
e, _ := timehlp.ConvertToTime("08:30")
256256
create(c, "123", util.TimeEntryDTO{
257257
Workspace: te.ID,
258258
UserID: te.UserID,
@@ -280,7 +280,7 @@ func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
280280
name: "split in three with end",
281281
args: []string{te.ID, "08:30", "9:00"},
282282
f: func(t *testing.T) cmdutil.Factory {
283-
end, _ := timehlp.ConvertToTime("2024-06-02 10:00")
283+
end, _ := timehlp.ConvertToTime("10:00")
284284
te := dto.TimeEntryImpl{
285285
WorkspaceID: w.ID,
286286
ID: "timeentryid",
@@ -293,10 +293,10 @@ func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
293293
),
294294
}
295295

296-
s, _ := timehlp.ConvertToTime("2024-06-02 08:30")
296+
s, _ := timehlp.ConvertToTime("08:30")
297297
f, c := getAndUpdate(t, te, s)
298298

299-
e, _ := timehlp.ConvertToTime("2024-06-02 09:00")
299+
e, _ := timehlp.ConvertToTime("09:00")
300300
create(c, "123", util.TimeEntryDTO{
301301
Workspace: te.ID,
302302
UserID: te.UserID,
@@ -342,7 +342,11 @@ func TestNewCmdSplitShouldCreateNewEntries(t *testing.T) {
342342
cmd.SetArgs(tt.args)
343343
_, err := cmd.ExecuteC()
344344

345-
if assert.True(t, called) || assert.NoError(t, err) {
345+
if assert.NoError(t, err) {
346+
return
347+
}
348+
349+
if assert.True(t, called) {
346350
return
347351
}
348352
})

0 commit comments

Comments
 (0)