-
Notifications
You must be signed in to change notification settings - Fork 0
/
godog_test.go
51 lines (34 loc) · 1.01 KB
/
godog_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
package clocksteps
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestClock_setError(t *testing.T) {
t.Parallel()
c := New()
err := c.set("foobar")
expectedError := `parsing time "foobar" as "2006-01-02": cannot parse "foobar" as "2006"`
assert.EqualError(t, err, expectedError)
}
func TestClock_addDateError(t *testing.T) {
t.Parallel()
c := New()
t.Run("invalid year", func(t *testing.T) {
t.Parallel()
err := c.addDate("foobar", "0", "0")
expectedError := `strconv.Atoi: parsing "foobar": invalid syntax`
assert.EqualError(t, err, expectedError)
})
t.Run("invalid month", func(t *testing.T) {
t.Parallel()
err := c.addDate("0", "foobar", "0")
expectedError := `strconv.Atoi: parsing "foobar": invalid syntax`
assert.EqualError(t, err, expectedError)
})
t.Run("invalid year", func(t *testing.T) {
t.Parallel()
err := c.addDate("0", "0", "foobar")
expectedError := `strconv.Atoi: parsing "foobar": invalid syntax`
assert.EqualError(t, err, expectedError)
})
}