-
Notifications
You must be signed in to change notification settings - Fork 0
/
models_test.go
72 lines (57 loc) · 1.51 KB
/
models_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"testing"
"time"
assert "github.com/stretchr/testify/assert"
)
func TestNewTimeSheetEntry_ShouldCreateAsExpected(t *testing.T) {
// arrange
tests := []struct {
date time.Time
id string
length string // in seconds
taskID string
taskName string
expectedStatus status
expectedIssueID string
}{
{time.Now(), "ID", "600", "1", "[XX-123] name", Unknown, "XX-123"},
}
for _, theory := range tests {
// act
item := WorkLogItem{
ID: theory.id,
Length: theory.length,
TaskID: theory.taskID,
TaskName: theory.taskName,
}
obj := NewTimeSheetEntry(theory.date, item)
duration, _ := time.ParseDuration(theory.length + "s")
assert.NotNil(t, obj)
assert.Equal(t, theory.expectedStatus, obj.Status)
assert.Equal(t, duration, obj.SpentTime)
assert.Equal(t, theory.expectedIssueID, obj.YouTrackIssueID)
}
}
func TestNewTimeSheetEntry_ShouldChangeStatusAsExpected(t *testing.T) {
// act
item := WorkLogItem{
ID: "1",
Length: "10",
TaskID: "theory.taskID",
TaskName: "theory.taskName",
}
obj := NewTimeSheetEntry(time.Now(), item)
obj.SetModified()
assert.Equal(t, Modified, obj.Status)
assert.Equal(t, ">", obj.Status.String())
obj.SetNew()
assert.Equal(t, New, obj.Status)
assert.Equal(t, "+", obj.Status.String())
obj.SetNotModified()
assert.Equal(t, NotModified, obj.Status)
assert.Equal(t, "=", obj.Status.String())
obj.SetUnknown()
assert.Equal(t, Unknown, obj.Status)
assert.Equal(t, "?", obj.Status.String())
}