This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
deployments_test.go
78 lines (60 loc) · 1.71 KB
/
deployments_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
package tugboat
import (
"errors"
"testing"
)
func TestDeploymentStarted(t *testing.T) {
d := &Deployment{}
d.Started("fake")
if got, want := d.Status, StatusStarted; got != want {
t.Fatalf("Status => %s; want %s", got, want)
}
if got, want := d.Provider, "fake"; got != want {
t.Fatalf("Provider => %s; want %s", got, want)
}
if d.StartedAt == nil {
t.Fatalf("expected StartedAt to not be nil")
}
}
func TestDeploymentFailed(t *testing.T) {
d := &Deployment{Status: StatusPending}
d.Failed()
if got, want := d.Status, StatusFailed; got != want {
t.Fatalf("Status => %s; want %s", got, want)
}
if got, want := d.prevStatus, StatusPending; got != want {
t.Fatalf("prevStatus => %s; want %s", got, want)
}
if d.CompletedAt == nil {
t.Fatalf("expected CompletedAt to not be nil")
}
}
func TestDeploymentSucceeded(t *testing.T) {
d := &Deployment{Status: StatusPending}
d.Succeeded()
if got, want := d.Status, StatusSucceeded; got != want {
t.Fatalf("Status => %s; want %s", got, want)
}
if got, want := d.prevStatus, StatusPending; got != want {
t.Fatalf("prevStatus => %s; want %s", got, want)
}
if d.CompletedAt == nil {
t.Fatalf("expected CompletedAt to not be nil")
}
}
func TestDeploymentErrored(t *testing.T) {
d := &Deployment{Status: StatusPending}
d.Errored(errors.New("boom"))
if got, want := d.Error, "boom"; got != want {
t.Fatalf("Error => %s; want %s", got, want)
}
if got, want := d.Status, StatusErrored; got != want {
t.Fatalf("Status => %s; want %s", got, want)
}
if got, want := d.prevStatus, StatusPending; got != want {
t.Fatalf("prevStatus => %s; want %s", got, want)
}
if d.CompletedAt == nil {
t.Fatalf("expected CompletedAt to not be nil")
}
}