-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathout_command_test.go
80 lines (62 loc) · 1.66 KB
/
out_command_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
73
74
75
76
77
78
79
80
package resource_test
import (
"io/ioutil"
"os"
"strings"
"time"
resource "github.com/concourse/time-resource"
"github.com/concourse/time-resource/models"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Out", func() {
var (
now time.Time
tmpdir string
source models.Source
response models.OutResponse
err error
)
BeforeEach(func() {
now = time.Now().UTC()
tmpdir, err = ioutil.TempDir("", "out-source")
Expect(err).NotTo(HaveOccurred())
source = models.Source{}
})
JustBeforeEach(func() {
command := resource.OutCommand{}
response, err = command.Run(models.OutRequest{
Source: source,
})
})
AfterEach(func() {
os.RemoveAll(tmpdir)
})
Context("when executed", func() {
JustBeforeEach(func() {
Expect(err).NotTo(HaveOccurred())
})
Context("when a location is specified", func() {
BeforeEach(func() {
loc, err := time.LoadLocation("America/Indiana/Indianapolis")
Expect(err).ToNot(HaveOccurred())
srcLoc := models.Location(*loc)
source.Location = &srcLoc
now = now.In(loc)
})
It("reports specified location's current time (offset: -0400) as the version", func() {
_, expectedOffset := now.Zone()
_, versionOffset := response.Version.Time.Zone()
Expect(versionOffset).To(Equal(expectedOffset))
})
})
Context("when a location is not specified", func() {
It("reports the current time (offset: 0000) as the version", func() {
// An example of response.Version.Time.String() is
// 2019-04-03 18:53:10.964705 +0000 UTC
contained := strings.Contains(response.Version.Time.String(), "0000")
Expect(contained).To(BeTrue())
})
})
})
})