~chipaca/ubuntu-push/session-refactor-002

« back to all changes in this revision

Viewing changes to client/client_test.go

  • Committer: John R. Lenton
  • Date: 2015-02-06 10:26:55 UTC
  • Revision ID: jlenton@gmail.com-20150206102655-elaqux14ezyvidr3
first step

Show diffs side-by-side

added added

removed removed

Lines of Context:
528
528
func (cs *clientSuite) TestDerivePollerSetup(c *C) {
529
529
        cs.writeTestConfig(map[string]interface{}{})
530
530
        cli := NewPushClient(cs.configPath, cs.leveldbPath)
531
 
        cli.session = new(session.ClientSession)
 
531
        cli.session = new(session.ConcreteSession)
532
532
        err := cli.configure()
533
533
        c.Assert(err, IsNil)
534
534
        expected := &poller.PollerSetup{
1031
1031
        cli.log = cs.log
1032
1032
        cli.systemImageInfo = siInfoRes
1033
1033
        c.Assert(cli.initSessionAndPoller(), IsNil)
1034
 
        cli.session.BroadcastCh = make(chan *session.BroadcastNotification, 1)
1035
 
        cli.session.BroadcastCh <- &session.BroadcastNotification{}
 
1034
        cli.session.(*session.ConcreteSession).BroadcastCh = make(chan *session.BroadcastNotification, 1)
 
1035
        cli.session.(*session.ConcreteSession).BroadcastCh <- &session.BroadcastNotification{}
1036
1036
 
1037
1037
        ch := make(chan bool, 1)
1038
1038
        go cli.doLoop(nopConn, func(_ *session.BroadcastNotification) error { ch <- true; return nil }, nopUcast, nopError, nopUnregister, nopAcct)
1044
1044
        cli.log = cs.log
1045
1045
        cli.systemImageInfo = siInfoRes
1046
1046
        c.Assert(cli.initSessionAndPoller(), IsNil)
1047
 
        cli.session.NotificationsCh = make(chan session.AddressedNotification, 1)
1048
 
        cli.session.NotificationsCh <- session.AddressedNotification{}
 
1047
        cli.session.(*session.ConcreteSession).NotificationsCh = make(chan session.AddressedNotification, 1)
 
1048
        cli.session.(*session.ConcreteSession).NotificationsCh <- session.AddressedNotification{}
1049
1049
 
1050
1050
        ch := make(chan bool, 1)
1051
1051
        go cli.doLoop(nopConn, nopBcast, func(session.AddressedNotification) error { ch <- true; return nil }, nopError, nopUnregister, nopAcct)
1057
1057
        cli.log = cs.log
1058
1058
        cli.systemImageInfo = siInfoRes
1059
1059
        c.Assert(cli.initSessionAndPoller(), IsNil)
1060
 
        cli.session.ErrCh = make(chan error, 1)
1061
 
        cli.session.ErrCh <- nil
 
1060
        cli.session.(*session.ConcreteSession).ErrCh = make(chan error, 1)
 
1061
        cli.session.(*session.ConcreteSession).ErrCh <- nil
1062
1062
 
1063
1063
        ch := make(chan bool, 1)
1064
1064
        go cli.doLoop(nopConn, nopBcast, nopUcast, func(error) { ch <- true }, nopUnregister, nopAcct)
1137
1137
 
1138
1138
        c.Assert(cli.initSessionAndPoller(), IsNil)
1139
1139
 
1140
 
        cli.session.BroadcastCh = make(chan *session.BroadcastNotification)
1141
 
        cli.session.ErrCh = make(chan error)
 
1140
        cli.session.(*session.ConcreteSession).BroadcastCh = make(chan *session.BroadcastNotification)
 
1141
        cli.session.(*session.ConcreteSession).ErrCh = make(chan error)
1142
1142
 
1143
1143
        // we use tick() to make sure things have been through the
1144
1144
        // event loop at least once before looking at things;
1165
1165
 
1166
1166
        //  * session.BroadcastCh to the notifications handler
1167
1167
        c.Check(d.bcastCount, Equals, 0)
1168
 
        cli.session.BroadcastCh <- positiveBroadcastNotification
 
1168
        cli.session.(*session.ConcreteSession).BroadcastCh <- positiveBroadcastNotification
1169
1169
        tick()
1170
1170
        c.Check(d.bcastCount, Equals, 1)
1171
1171
 
1172
1172
        //  * session.ErrCh to the error handler
1173
 
        cli.session.ErrCh <- nil
 
1173
        cli.session.(*session.ConcreteSession).ErrCh <- nil
1174
1174
        tick()
1175
1175
        c.Check(cs.log.Captured(), Matches, "(?ms).*session exited.*")
1176
1176
}