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") }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
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) }
func (s *stubSuite) TestCheckCallNamesEmptyFail(c *gc.C) { c.ExpectFailure(`Stub.CheckCall should fail when no calls have been made`) s.stub.CheckCallNames(c, "aMethod") }
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) }
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) }
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) }
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) }
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) }