Exemplo n.º 1
0
func (s *testSuite) TestGlobal(c *C) {
	global := db.NewGlobal()
	c.Assert(s.client.Set(global), IsNil)
	global2 := db.NewGlobal()
	c.Assert(s.client.Get(global2), IsNil)
	global = global.Canonical()
	c.Assert(global, DeepEquals, global2)
}
Exemplo n.º 2
0
func (s *testSuite) TestGlobalEmpty(c *C) {
	c.Assert(s.client.Set(db.NewGlobal()), IsNil)
	global := db.NewGlobal()
	c.Assert(s.client.Get(global), IsNil)

	c.Assert(global.TTL, Equals, db.DefaultGlobalTTL)
	c.Assert(global.MountPath, Equals, db.DefaultMountPath)
	c.Assert(global.Timeout, Equals, db.DefaultTimeout)
}
Exemplo n.º 3
0
func (s *testSuite) TestGlobalWatch(c *C) {
	global := db.NewGlobal()

	globalChan, errChan := s.client.Watch(global)
	c.Assert(s.client.Set(global), IsNil)
	select {
	case err := <-errChan:
		c.Assert(err, IsNil) // will always fail
	case tmp := (<-globalChan):
		global2 := tmp.(*db.Global)
		c.Assert(global2, NotNil)
		global2 = global2.Canonical()
		c.Assert(global, DeepEquals, global2)
	}

	c.Assert(s.client.WatchStop(global), IsNil)
}
Exemplo n.º 4
0
func (s *testSuite) TestGlobalWatch(c *C) {
	global := db.NewGlobal()

	// XXX this leaks but w/e, we should probably implement a stop chan. not a
	// real world problem
	globalChan, errChan := s.client.Watch(global)

	c.Assert(s.client.Set(global), IsNil)
	select {
	case err := <-errChan:
		c.Assert(err, IsNil) // will always fail
	case tmp := (<-globalChan):
		global2 := tmp.(*db.Global)
		c.Assert(global2, NotNil)
		global2 = global2.Canonical()
		c.Assert(global, DeepEquals, global2)
	}
}