本文整理汇总了Golang中github.com/juju/testing/filetesting.File.Check方法的典型用法代码示例。如果您正苦于以下问题:Golang File.Check方法的具体用法?Golang File.Check怎么用?Golang File.Check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/testing/filetesting.File
的用法示例。
在下文中一共展示了File.Check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestUpgradeConflictRevertRetryDifferentCharm
func (s *ManifestDeployerSuite) TestUpgradeConflictRevertRetryDifferentCharm(c *gc.C) {
// Create base install and add a user file.
s.deployCharm(c, 1,
ft.File{"shared-file", "old", 0755},
ft.File{"old-file", "old", 0644},
)
userFile := ft.File{"user-file", "user", 0644}.Create(c, s.targetPath)
// Create a charm upgrade that never works (but still writes a bunch of files),
// and deploy it.
badUpgradeContent := ft.Entries{
ft.File{"shared-file", "bad", 0644},
ft.File{"bad-file", "bad", 0644},
}
badCharm := mockBundle{
paths: set.NewStrings(badUpgradeContent.Paths()...),
expand: func(targetPath string) error {
badUpgradeContent.Create(c, targetPath)
return fmt.Errorf("oh noes")
},
}
badInfo := s.addMockCharm(c, 2, badCharm)
err := s.deployer.Stage(badInfo, nil)
c.Assert(err, gc.IsNil)
err = s.deployer.Deploy()
c.Assert(err, gc.Equals, charm.ErrConflict)
// Notify the Deployer that it'll be expected to revert the changes from
// the last attempt.
err = s.deployer.NotifyRevert()
c.Assert(err, gc.IsNil)
// Create a charm upgrade that creates a bunch of different files, without
// error, and deploy it; check user files are preserved, and nothing from
// charm 1 or 2 is.
s.deployCharm(c, 3,
ft.File{"shared-file", "new", 0755},
ft.File{"new-file", "new", 0644},
)
userFile.Check(c, s.targetPath)
ft.Removed{"old-file"}.Check(c, s.targetPath)
ft.Removed{"bad-file"}.Check(c, s.targetPath)
}
示例2: TestExtractAllOverwriteSymlinks
func (s *ZipSuite) TestExtractAllOverwriteSymlinks(c *gc.C) {
name := "some-symlink"
for i, test := range []ft.Entry{
ft.File{name, "content", 0644},
ft.Dir{name, 0751},
ft.Symlink{name, "wherever"},
} {
c.Logf("test %d: %#v", i, test)
targetPath := c.MkDir()
original := ft.File{"original", "content", 0644}
original.Create(c, targetPath)
ft.Symlink{name, "original"}.Create(c, targetPath)
reader := s.makeZip(c, test)
err := zip.ExtractAll(reader, targetPath)
c.Check(err, gc.IsNil)
test.Check(c, targetPath)
original.Check(c, targetPath)
}
}
示例3: TestPathological
func (s *ConverterSuite) TestPathological(c *gc.C) {
initial := s.bundles.AddCustomBundle(c, charmURL(1), func(path string) {
ft.File{"common", "initial", 0644}.Create(c, path)
ft.File{"initial", "blah", 0644}.Create(c, path)
})
staged := s.bundles.AddCustomBundle(c, charmURL(2), func(path string) {
ft.File{"common", "staged", 0644}.Create(c, path)
ft.File{"user", "badwrong", 0644}.Create(c, path)
})
final := s.bundles.AddCustomBundle(c, charmURL(3), func(path string) {
ft.File{"common", "final", 0644}.Create(c, path)
ft.File{"final", "blah", 0644}.Create(c, path)
})
gitDeployer := charm.NewGitDeployer(s.targetPath, s.dataPath, s.bundles)
err := gitDeployer.Stage(initial, nil)
c.Assert(err, gc.IsNil)
err = gitDeployer.Deploy()
c.Assert(err, gc.IsNil)
preserveUser := ft.File{"user", "preserve", 0644}.Create(c, s.targetPath)
err = gitDeployer.Stage(staged, nil)
c.Assert(err, gc.IsNil)
deployer, err := charm.NewDeployer(s.targetPath, s.dataPath, s.bundles)
c.Assert(err, gc.IsNil)
err = charm.FixDeployer(&deployer)
c.Assert(err, gc.IsNil)
err = deployer.Stage(final, nil)
c.Assert(err, gc.IsNil)
err = deployer.Deploy()
c.Assert(err, gc.IsNil)
ft.Removed{".git"}.Check(c, s.targetPath)
ft.Removed{"initial"}.Check(c, s.targetPath)
ft.Removed{"staged"}.Check(c, s.targetPath)
ft.File{"common", "final", 0644}.Check(c, s.targetPath)
preserveUser.Check(c, s.targetPath)
}