Пример #1
0
func (s *stubSuite) TestCheckCallNamesMissingCall(c *gc.C) {
	s.stub.AddCall("first", "arg")
	s.stub.AddCall("third")

	c.ExpectFailure(`the "standard" Stub.CheckCallNames call should fail here`)
	s.stub.CheckCallNames(c, "first", "second", "third")
}
Пример #2
0
func (s *stubSuite) TestCheckNoCalls(c *gc.C) {
	s.stub.CheckNoCalls(c)

	s.stub.AddCall("method", "arg")
	c.ExpectFailure(`the "standard" Stub.CheckNoCalls call should fail here`)
	s.stub.CheckNoCalls(c)
}
Пример #3
0
func (*migrateSuite) TestMigrateAll(c *gc.C) {
	c.ExpectFailure("all bundles do not migrate successfully")
	passed, total := 0, 0
	doAllBundles(c, func(c *gc.C, id string, data []byte) {
		c.Logf("\nmigrate test %s", id)
		ok := true
		bundles, err := Migrate(data, func(id *charm.Reference) (bool, error) {
			meta, err := getCharm(id)
			if err != nil {
				return false, err
			}
			return meta.Meta().Subordinate, nil
		})
		if err != nil {
			c.Logf("cannot migrate: %v", err)
			ok = false
		}
		for _, bundle := range bundles {
			ok = checkBundleData(c, bundle) && ok
		}
		if ok {
			passed++
		}
		total++
	})
	c.Logf("%d/%d passed", passed, total)
	c.Check(passed, gc.Equals, total)
}
Пример #4
0
func (s *EntrySuite) TestEntriesCreateFailure(c *gc.C) {
	c.ExpectFailure("cannot create an entry")
	ft.Entries{
		ft.File{"good", "good", 0750},
		ft.File{"nodir/bad", "bad", 0640},
	}.Create(c, s.basePath)
}
Пример #5
0
func (s *EntrySuite) TestRemovedCreateFailure(c *gc.C) {
	ft.File{"some-file", "content", 0644}.Create(c, s.basePath)
	os.Chmod(s.basePath, 0444)
	defer os.Chmod(s.basePath, 0777)
	c.ExpectFailure("should fail to remove file")
	ft.Removed{"some-file"}.Create(c, s.basePath)
}
Пример #6
0
func (s *stubSuite) TestCheckCallMissingCall(c *gc.C) {
	s.stub.AddCall("first", "arg")
	s.stub.AddCall("third")

	c.ExpectFailure(`the "standard" Stub.CheckCall call should fail here`)
	s.checkCallStandard(c)
}
Пример #7
0
func (s *stubSuite) TestCheckCallNamesUnexpected(c *gc.C) {
	s.stub.AddCall("first", "arg")
	s.stub.AddCall("second", 1, 2, 4)
	s.stub.AddCall("third")

	c.ExpectFailure(`Stub.CheckCall should fail when no calls have been made`)
	s.stub.CheckCallNames(c)
}
Пример #8
0
func (s *stubSuite) TestCheckCallWrongArgs(c *gc.C) {
	s.stub.AddCall("first", "arg")
	s.stub.AddCall("second", 1, 2, 4)
	s.stub.AddCall("third")

	c.ExpectFailure(`the "standard" Stub.CheckCall call should fail here`)
	s.checkCallStandard(c)
}
Пример #9
0
func (s *EntrySuite) TestEntriesCheckFailure(c *gc.C) {
	goodFile := ft.File{"good", "good", 0751}.Create(c, s.basePath)
	c.ExpectFailure("entry does not exist")
	ft.Entries{
		goodFile,
		ft.File{"bad", "", 0750},
	}.Check(c, s.basePath)
}
Пример #10
0
func (s *stubSuite) TestCheckCallsWrongName(c *gc.C) {
	s.stub.AddCall("first", "arg")
	s.stub.AddCall("oops", 1, 2, 3)
	s.stub.AddCall("third")

	c.ExpectFailure(`the "standard" Stub.CheckCalls call should fail`)
	s.checkCallsStandard(c)
}
Пример #11
0
func (s *EntrySuite) TestFileCheckFailureNoExist(c *gc.C) {
	c.ExpectFailure("shouldn't find file that does not exist")
	ft.File{"furble", "pingle", 0740}.Check(c, s.basePath)
}
Пример #12
0
func (s *EntrySuite) TestFileCheckFailureBadData(c *gc.C) {
	ft.File{"furble", "pingle", 0740}.Check(c, s.basePath)
	c.ExpectFailure("shouldn't pass with different content")
	ft.File{"furble", "wrongle", 0740}.Check(c, s.basePath)
}
Пример #13
0
func (s *EntrySuite) TestFileCheckFailureBadPerm(c *gc.C) {
	ft.File{"furble", "pingle", 0644}.Create(c, s.basePath)
	c.ExpectFailure("shouldn't pass with different perms")
	ft.File{"furble", "pingle", 0740}.Check(c, s.basePath)
}
Пример #14
0
func (s *EntrySuite) TestFileCreateFailure(c *gc.C) {
	c.ExpectFailure("should fail to create file in missing dir")
	ft.File{"missing/foobar", "hello", 0644}.Create(c, s.basePath)
}
Пример #15
0
func (s *EntrySuite) TestSymlinkCheckFailureNoExist(c *gc.C) {
	c.ExpectFailure("should not accept symlink that doesn't exist")
	ft.Symlink{"link", "target"}.Check(c, s.basePath)
}
Пример #16
0
func (s *EntrySuite) TestRemovedCheckFailureDir(c *gc.C) {
	ft.Dir{"some-dir", 0755}.Create(c, s.basePath)
	c.ExpectFailure("should not accept dir")
	ft.Removed{"some-dir"}.Check(c, s.basePath)
}
Пример #17
0
func (s *EntrySuite) TestRemovedCheckFailureFile(c *gc.C) {
	ft.File{"some-file", "", 0644}.Create(c, s.basePath)
	c.ExpectFailure("should not accept file")
	ft.Removed{"some-file"}.Check(c, s.basePath)
}
Пример #18
0
func (s *EntrySuite) TestDirCheckFailureFile(c *gc.C) {
	ft.File{"blah", "content", 0644}.Create(c, s.basePath)
	c.ExpectFailure("shouldn't accept file")
	ft.Dir{"blah", 0644}.Check(c, s.basePath)
}
Пример #19
0
func (s *EntrySuite) TestSymlinkCheckFailureDir(c *gc.C) {
	ft.Dir{"link", 0755}.Create(c, s.basePath)
	c.ExpectFailure("should not accept dir")
	ft.Symlink{"link", "different"}.Check(c, s.basePath)
}
Пример #20
0
func (s *EntrySuite) TestSymlinkCheckFailureFile(c *gc.C) {
	ft.File{"link", "target", 0644}.Create(c, s.basePath)
	c.ExpectFailure("should not accept plain file")
	ft.Symlink{"link", "target"}.Check(c, s.basePath)
}
Пример #21
0
func (s *EntrySuite) TestSymlinkCheckFailureBadTarget(c *gc.C) {
	ft.Symlink{"link", "target"}.Create(c, s.basePath)
	c.ExpectFailure("should not accept different target")
	ft.Symlink{"link", "different"}.Check(c, s.basePath)
}
Пример #22
0
func (s *EntrySuite) TestFileCheckFailureSymlink(c *gc.C) {
	ft.Symlink{"link", "file"}.Create(c, s.basePath)
	ft.File{"file", "content", 0644}.Create(c, s.basePath)
	c.ExpectFailure("shouldn't accept symlink, even if pointing to matching file")
	ft.File{"link", "content", 0644}.Check(c, s.basePath)
}
Пример #23
0
func (s *EntrySuite) TestFileCheckFailureDir(c *gc.C) {
	ft.Dir{"furble", 0740}.Create(c, s.basePath)
	c.ExpectFailure("shouldn't accept dir")
	ft.File{"furble", "pingle", 0740}.Check(c, s.basePath)
}
Пример #24
0
func (s *EntrySuite) TestDirCheckFailureSymlink(c *gc.C) {
	ft.Symlink{"link", "dir"}.Create(c, s.basePath)
	ft.Dir{"dir", 0644}.Create(c, s.basePath)
	c.ExpectFailure("shouldn't accept symlink, even if pointing to matching dir")
	ft.Dir{"link", 0644}.Check(c, s.basePath)
}
Пример #25
0
func (s *stubSuite) TestCheckCallNamesEmptyFail(c *gc.C) {
	c.ExpectFailure(`Stub.CheckCall should fail when no calls have been made`)
	s.stub.CheckCallNames(c, "aMethod")
}
Пример #26
0
func (s *EntrySuite) TestSymlinkCreateFailure(c *gc.C) {
	c.ExpectFailure("should fail to create symlink in missing dir")
	ft.Symlink{"missing/link", "target"}.Create(c, s.basePath)
}
Пример #27
0
func (s *EntrySuite) TestDirCheckFailureNoExist(c *gc.C) {
	c.ExpectFailure("shouldn't find dir that does not exist")
	ft.Dir{"fooble", 0751}.Check(c, s.basePath)
}
Пример #28
0
func (s *EntrySuite) TestDirCheckFailureBadPerm(c *gc.C) {
	ft.Dir{"furble", 0740}.Check(c, s.basePath)
	c.ExpectFailure("shouldn't pass with different perms")
	ft.Dir{"furble", 0755}.Check(c, s.basePath)
}
Пример #29
0
func (s *EntrySuite) TestRemovedCheckFailureSymlink(c *gc.C) {
	ft.Symlink{"some-link", "target"}.Create(c, s.basePath)
	c.ExpectFailure("should not accept symlink")
	ft.Removed{"some-link"}.Check(c, s.basePath)
}
Пример #30
0
func (s *EntrySuite) TestDirCreateFailure(c *gc.C) {
	os.Chmod(s.basePath, 0444)
	defer os.Chmod(s.basePath, 0777)
	c.ExpectFailure("should fail to create file")
	ft.Dir{"foobar", 0750}.Create(c, s.basePath)
}