Ejemplo n.º 1
0
func (s *fakeSession) checkLastArgs(c *gc.C, ts bson.MongoTimestamp, ids []int64) {
	select {
	case <-time.After(coretesting.LongWait):
		c.Logf("timeout getting iter args - test problem")
		c.FailNow()
	case res := <-s.args:
		c.Check(res.timestamp, gc.Equals, ts)
		c.Check(res.excludeIds, gc.DeepEquals, ids)
	}
}
Ejemplo n.º 2
0
func (r *StubRunner) checkCallIDs(c *gc.C, methName string, skipMismatch bool, expected []string) {
	var ids []string
	for _, call := range r.Stub.Calls() {
		if !r.validMethodName(call.FuncName) {
			c.Logf("invalid called func name %q (must be one of %#v)", call.FuncName, runnerMethodNames)
			c.FailNow()
		}
		if methName != "" {
			if skipMismatch && call.FuncName != methName {
				continue
			}
			c.Check(call.FuncName, gc.Equals, methName)
		}
		ids = append(ids, call.Args[0].(string))
	}
	sort.Strings(ids)
	sort.Strings(expected)
	c.Check(ids, jc.DeepEquals, expected)
}
Ejemplo n.º 3
0
func (s *Suite) Test_isEmptyDir_and_getSubdirs(c *check.C) {
	s.CreateTmpFile(c, "CVS/Entries", "dummy\n")

	c.Check(isEmptyDir(s.tmpdir), equals, true)
	c.Check(getSubdirs(s.tmpdir), check.DeepEquals, []string(nil))

	s.CreateTmpFile(c, "somedir/file", "")

	c.Check(isEmptyDir(s.tmpdir), equals, false)
	c.Check(getSubdirs(s.tmpdir), check.DeepEquals, []string{"somedir"})

	if nodir := s.tmpdir + "/nonexistent"; true {
		c.Check(isEmptyDir(nodir), equals, true) // Counts as empty.
		defer s.ExpectFatalError(func() {
			c.Check(s.Output(), check.Matches, `FATAL: (.+): Cannot be read: open (.+): (.+)\n`)
		})
		c.Check(getSubdirs(nodir), check.DeepEquals, []string(nil))
		c.FailNow()
	}
}