-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
50 lines (44 loc) · 1.15 KB
/
main_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
package main
import (
"testing"
"time"
"github.com/moov-io/base"
"github.com/moov-io/base/log"
"github.com/stretchr/testify/require"
)
func TestRunner(t *testing.T) {
nyc, _ := time.LoadLocation("America/New_York")
when := time.Date(2021, time.December, 2, 12, 0, 0, 0, nyc)
rr := &runner{
logger: log.NewNopLogger(),
now: base.NewTime(when),
args: []string{"date", "-u"},
}
output, err := rr.run()
require.NoError(t, err)
require.Contains(t, string(output), "UTC")
}
func TestRunner__Holiday(t *testing.T) {
nyc, _ := time.LoadLocation("America/New_York")
when := time.Date(2021, time.July, 4, 12, 0, 0, 0, nyc)
rr := &runner{
logger: log.NewNopLogger(),
now: base.NewTime(when),
args: []string{"date", "-u"},
}
output, err := rr.run()
require.NoError(t, err)
require.Empty(t, output)
}
func TestRunner__Error(t *testing.T) {
nyc, _ := time.LoadLocation("America/New_York")
when := time.Date(2021, time.December, 2, 12, 0, 0, 0, nyc)
rr := &runner{
logger: log.NewNopLogger(),
now: base.NewTime(when),
args: []string{"date", "-invalid"},
}
output, err := rr.run()
require.Error(t, err)
require.Empty(t, output)
}