~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/status_unit_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
        "github.com/juju/juju/state"
13
13
        "github.com/juju/juju/status"
 
14
        "github.com/juju/juju/testing"
14
15
)
15
16
 
16
17
type UnitStatusSuite struct {
36
37
}
37
38
 
38
39
func (s *UnitStatusSuite) TestSetUnknownStatus(c *gc.C) {
39
 
        now := time.Now()
 
40
        now := testing.ZeroTime()
40
41
        sInfo := status.StatusInfo{
41
42
                Status:  status.Status("vliegkat"),
42
43
                Message: "orville",
49
50
}
50
51
 
51
52
func (s *UnitStatusSuite) TestSetOverwritesData(c *gc.C) {
52
 
        now := time.Now()
 
53
        now := testing.ZeroTime()
53
54
        sInfo := status.StatusInfo{
54
 
                Status:  status.StatusActive,
 
55
                Status:  status.Active,
55
56
                Message: "healthy",
56
57
                Data: map[string]interface{}{
57
58
                        "pew.pew": "zap",
69
70
}
70
71
 
71
72
func (s *UnitStatusSuite) checkGetSetStatus(c *gc.C) {
72
 
        now := time.Now()
 
73
        now := testing.ZeroTime()
73
74
        sInfo := status.StatusInfo{
74
 
                Status:  status.StatusActive,
 
75
                Status:  status.Active,
75
76
                Message: "healthy",
76
77
                Data: map[string]interface{}{
77
78
                        "$ping": map[string]interface{}{
87
88
 
88
89
        statusInfo, err := unit.Status()
89
90
        c.Check(err, jc.ErrorIsNil)
90
 
        c.Check(statusInfo.Status, gc.Equals, status.StatusActive)
 
91
        c.Check(statusInfo.Status, gc.Equals, status.Active)
91
92
        c.Check(statusInfo.Message, gc.Equals, "healthy")
92
93
        c.Check(statusInfo.Data, jc.DeepEquals, map[string]interface{}{
93
94
                "$ping": map[string]interface{}{
122
123
        err := s.unit.Destroy()
123
124
        c.Assert(err, jc.ErrorIsNil)
124
125
 
125
 
        now := time.Now()
 
126
        now := testing.ZeroTime()
126
127
        sInfo := status.StatusInfo{
127
 
                Status:  status.StatusActive,
 
128
                Status:  status.Active,
128
129
                Message: "not really",
129
130
                Since:   &now,
130
131
        }
137
138
}
138
139
 
139
140
func (s *UnitStatusSuite) TestSetUnitStatusSince(c *gc.C) {
140
 
        now := time.Now()
 
141
        now := testing.ZeroTime()
141
142
        sInfo := status.StatusInfo{
142
 
                Status:  status.StatusMaintenance,
 
143
                Status:  status.Maintenance,
143
144
                Message: "",
144
145
                Since:   &now,
145
146
        }
154
155
        // Setting the same status a second time also updates the timestamp.
155
156
        now = now.Add(1 * time.Second)
156
157
        sInfo = status.StatusInfo{
157
 
                Status:  status.StatusMaintenance,
 
158
                Status:  status.Maintenance,
158
159
                Message: "",
159
160
                Since:   &now,
160
161
        }