예제 #1
0
func (s *ArrayGroupSuite) TestGetEmptyArray(c *chk.C) {
	res, err := arrayClient.GetEmpty()
	if err != nil {
		c.SucceedNow()
	}
	c.Assert(*res.Value, chk.DeepEquals, []int32{})
}
예제 #2
0
// convert null to 0 - Int default value
// {1, null, 0} ---> {1,0,0}
func (s *ArrayGroupSuite) TestGetIntInvalidNull(c *chk.C) {
	res, err := arrayClient.GetIntInvalidNull()
	if err != nil {
		c.SucceedNow()
	}
	c.Assert(*res.Value, chk.DeepEquals, []int32{1, 0, 0})
}
예제 #3
0
// convert null to 0 - Float default value
// {1, null, 0} ---> {1,0,0}
func (s *ArrayGroupSuite) TestGetFloatInvalidNull(c *chk.C) {
	res, err := arrayClient.GetFloatInvalidNull()
	if err != nil {
		c.SucceedNow()
	}
	c.Assert(*res.Value, chk.DeepEquals, []float64{0, 0, -1.2e20})
}
예제 #4
0
func (s *DurationSuite) TestGetInvalidDuration(c *chk.C) {
	res, err := durationClient.GetInvalid()
	if err != nil {
		c.SucceedNow()
	}
	_, err = time.ParseDuration(*res.Value)
	c.Assert(err, chk.NotNil)
}
예제 #5
0
func (s *PublishSuite) TestParseReference(c *gc.C) {
	addMeta(c, s.branch, "")

	cmd := &publishCommand{}
	cmd.ChangePushLocation(func(location string) string {
		c.Assert(location, gc.Equals, "lp:charms/precise/wordpress")
		c.SucceedNow()
		panic("unreachable")
	})

	_, err := testing.RunCommandInDir(c, modelcmd.Wrap(cmd), []string{"precise/wordpress"}, s.dir)
	c.Assert(err, jc.ErrorIsNil)
	c.Fatal("shouldn't get here; location closure didn't run?")
}
예제 #6
0
func (s *RootKeyStorageSuite) TestEnsureIndex(c *gc.C) {
	keys := mgostorage.NewRootKeys(5)
	err := keys.EnsureIndex(s.coll())
	c.Assert(err, gc.IsNil)

	// This code can take up to 60s to run; there's no way
	// to force it to run more quickly, but it provides reassurance
	// that the code actually works.
	// Reenable the rest of this test if concerned about index behaviour.

	c.SucceedNow()

	_, id1, err := keys.NewStorage(s.coll(), mgostorage.Policy{
		ExpiryDuration: 100 * time.Millisecond,
	}).RootKey()
	c.Assert(err, gc.IsNil)

	_, id2, err := keys.NewStorage(s.coll(), mgostorage.Policy{
		ExpiryDuration: time.Hour,
	}).RootKey()
	c.Assert(err, gc.IsNil)
	c.Assert(id2, gc.Not(gc.Equals), id1)

	// Sanity check that the keys are in the collection.
	n, err := s.coll().Find(nil).Count()
	c.Assert(err, gc.IsNil)
	c.Assert(n, gc.Equals, 2)
	for i := 0; i < 100; i++ {
		n, err := s.coll().Find(nil).Count()
		c.Assert(err, gc.IsNil)
		switch n {
		case 1:
			c.SucceedNow()
		case 2:
			time.Sleep(time.Second)
		default:
			c.Fatalf("unexpected key count %v", n)
		}
	}
	c.Fatalf("key was never removed from database")
}