~ps-jenkins/ubuntu-push/ubuntu-vivid-proposed

« back to all changes in this revision

Viewing changes to bus/connectivity/connectivity_test.go

  • Committer: john.lenton at canonical
  • Date: 2014-01-26 12:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: john.lenton@canonical.com-20140126121751-hyrco9bxh8sfk5vm
first publishable iteration of the actual client.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
// when given a working config and bus, Start() will work
59
59
func (s *ConnSuite) TestStartWorks(c *C) {
60
60
        endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Work(true), uint32(networkmanager.Connecting))
61
 
        cs := connectedState{config: Config{}, log: nullog, endp: endp}
 
61
        cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
62
62
 
63
63
        c.Check(cs.start(), Equals, networkmanager.Connecting)
64
64
}
66
66
// if the bus fails a couple of times, we're still OK
67
67
func (s *ConnSuite) TestStartRetriesConnect(c *C) {
68
68
        endp := testingbus.NewTestingEndpoint(condition.Fail2Work(2), condition.Work(true), uint32(networkmanager.Connecting))
69
 
        cs := connectedState{config: Config{}, log: nullog, endp: endp}
 
69
        cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
70
70
 
71
71
        c.Check(cs.start(), Equals, networkmanager.Connecting)
72
72
        c.Check(cs.connAttempts, Equals, uint32(3)) // 1 more than the Fail2Work
75
75
// when the calls to NetworkManager fail for a bit, we're still OK
76
76
func (s *ConnSuite) TestStartRetriesCall(c *C) {
77
77
        endp := testingbus.NewTestingEndpoint(condition.Work(true), condition.Fail2Work(5), uint32(networkmanager.Connecting))
78
 
        cs := connectedState{config: Config{}, log: nullog, endp: endp}
 
78
        cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
79
79
 
80
80
        c.Check(cs.start(), Equals, networkmanager.Connecting)
81
81
 
93
93
        endp := testingbus.NewTestingEndpoint(condition.Work(true), nmcond,
94
94
                uint32(networkmanager.Connecting),
95
95
                uint32(networkmanager.ConnectedGlobal))
96
 
        cs := connectedState{config: Config{}, log: nullog, endp: endp}
 
96
        cs := connectedState{config: ConnectivityConfig{}, log: nullog, endp: endp}
97
97
 
98
98
        c.Check(cs.start(), Equals, networkmanager.Connecting)
99
99
        c.Check(cs.connAttempts, Equals, uint32(2))
109
109
        var webget_p condition.Interface = condition.Work(true)
110
110
        recheck_timeout := 50 * time.Millisecond
111
111
 
112
 
        cfg := Config{
 
112
        cfg := ConnectivityConfig{
113
113
                RecheckTimeout: config.ConfigTimeDuration{recheck_timeout},
114
114
        }
115
115
        ch := make(chan networkmanager.State, 10)
184
184
        ts := httptest.NewServer(mkHandler(staticText))
185
185
        defer ts.Close()
186
186
 
187
 
        cfg := Config{
 
187
        cfg := ConnectivityConfig{
188
188
                ConnectivityCheckURL: ts.URL,
189
189
                ConnectivityCheckMD5: staticHash,
190
190
                RecheckTimeout:       config.ConfigTimeDuration{time.Second},