本文整理汇总了Golang中launchpad/net/gocheck.C.GetTestLog方法的典型用法代码示例。如果您正苦于以下问题:Golang C.GetTestLog方法的具体用法?Golang C.GetTestLog怎么用?Golang C.GetTestLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gocheck.C
的用法示例。
在下文中一共展示了C.GetTestLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLogfAndGetTestLog
func (s *BootstrapS) TestLogfAndGetTestLog(c *gocheck.C) {
c.Logf("Hello %v", "there!")
log := c.GetTestLog()
if log != "Hello there!\n" {
critical(fmt.Sprintf("Logf() or GetTestLog() is not working! Got: %#v", log))
}
}
示例2: TestLog
func (*logSuite) TestLog(c *gc.C) {
logger := loggo.GetLogger("test")
jujuLogger := loggo.GetLogger("juju")
logConfig = "<root>=DEBUG;juju=TRACE"
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
var suite LoggingSuite
suite.SetUpSuite(c)
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.DEBUG)
c.Assert(jujuLogger.EffectiveLogLevel(), gc.Equals, loggo.TRACE)
logger.Debugf("message 1")
logger.Tracef("message 2")
jujuLogger.Tracef("message 3")
c.Assert(c.GetTestLog(), gc.Matches,
".*DEBUG test message 1\n"+
".*TRACE juju message 3\n",
)
suite.TearDownSuite(c)
logger.Debugf("message 1")
logger.Tracef("message 2")
jujuLogger.Tracef("message 3")
c.Assert(c.GetTestLog(), gc.Matches,
".*DEBUG test message 1\n"+
".*TRACE juju message 3\n",
)
c.Assert(logger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
c.Assert(jujuLogger.EffectiveLogLevel(), gc.Equals, loggo.WARNING)
}
示例3: SetUpTest
func (s *logSuite) SetUpTest(c *gc.C) {
s.LoggingSuite.SetUpTest(c)
// The SetUpTest resets the logging levels.
logger.SetLogLevel(loggo.INFO)
logger.Infof("testing-SetUpTest")
c.Assert(c.GetTestLog(), gc.Matches, ".*INFO test testing-SetUpTest\n")
}
示例4: TestLog
func (s *logSuite) TestLog(c *gc.C) {
logger.Infof("testing-Test")
c.Assert(c.GetTestLog(), gc.Matches,
".*INFO test testing-SetUpTest\n"+
".*INFO test testing-Test\n",
)
}
示例5: TestManagerWarnsAboutUnknownOption
func (*LxcSuite) TestManagerWarnsAboutUnknownOption(c *gc.C) {
_, err := lxc.NewContainerManager(container.ManagerConfig{
container.ConfigName: "BillyBatson",
"shazam": "Captain Marvel",
})
c.Assert(err, gc.IsNil)
c.Assert(c.GetTestLog(), jc.Contains, `WARNING juju.container unused config option: "shazam" -> "Captain Marvel"`)
}
示例6: TestMacOSXSeriesFromKernelVersionError
func (*kernelVersionSuite) TestMacOSXSeriesFromKernelVersionError(c *gc.C) {
// We suppress the actual error in favor of returning "unknown", but we
// do log the error
series, err := version.MacOSXSeriesFromKernelVersion(sysctlError)
c.Assert(err, gc.ErrorMatches, "no such syscall")
c.Assert(series, gc.Equals, "unknown")
c.Check(c.GetTestLog(), gc.Matches, ".* juju.version unable to determine OS version: no such syscall\n")
}
示例7: TestMinLogger
func (s *BootstrapS) TestMinLogger(c *gocheck.C) {
var logger minLogger
logger = log.New(os.Stderr, "", 0)
logger = c
logger.Output(0, "Hello there")
expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n`
output := c.GetTestLog()
c.Assert(output, gocheck.Matches, expected)
}
示例8: TestWarning
func (s *StoreSuite) TestWarning(c *gc.C) {
charmURL := charm.MustParseURL("cs:series/unwise")
expect := `.* WARNING juju.charm charm store reports for "cs:series/unwise": foolishness` + "\n"
r, err := charm.Latest(s.store, charmURL)
c.Assert(r, gc.Equals, 23)
c.Assert(err, gc.IsNil)
c.Assert(c.GetTestLog(), gc.Matches, expect)
ch, err := s.store.Get(charmURL)
c.Assert(ch, gc.NotNil)
c.Assert(err, gc.IsNil)
c.Assert(c.GetTestLog(), gc.Matches, expect+expect)
}
示例9: TestEnsureServer
func (s *MongoSuite) TestEnsureServer(c *gc.C) {
dataDir := c.MkDir()
dbDir := filepath.Join(dataDir, "db")
namespace := "namespace"
mockShellCommand(c, &s.CleanupSuite, "apt-get")
err := mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
c.Assert(err, gc.IsNil)
testJournalDirs(dbDir, c)
assertInstalled := func() {
c.Assert(s.installed, gc.HasLen, 1)
conf := s.installed[0]
c.Assert(conf.Name, gc.Equals, "juju-db-namespace")
c.Assert(conf.InitDir, gc.Equals, "/etc/init")
c.Assert(conf.Desc, gc.Equals, "juju state database")
c.Assert(conf.Cmd, gc.Matches, regexp.QuoteMeta(s.mongodPath)+".*")
// TODO(nate) set Out so that mongod output goes somewhere useful?
c.Assert(conf.Out, gc.Equals, "")
}
assertInstalled()
contents, err := ioutil.ReadFile(s.mongodConfigPath)
c.Assert(err, gc.IsNil)
c.Assert(contents, jc.DeepEquals, []byte("ENABLE_MONGODB=no"))
contents, err = ioutil.ReadFile(mongo.SSLKeyPath(dataDir))
c.Assert(err, gc.IsNil)
c.Assert(string(contents), gc.Equals, testInfo.Cert+"\n"+testInfo.PrivateKey)
contents, err = ioutil.ReadFile(mongo.SharedSecretPath(dataDir))
c.Assert(err, gc.IsNil)
c.Assert(string(contents), gc.Equals, testInfo.SharedSecret)
s.installed = nil
// now check we can call it multiple times without error
err = mongo.EnsureServer(makeEnsureServerParams(dataDir, namespace))
c.Assert(err, gc.IsNil)
assertInstalled()
// make sure that we log the version of mongodb as we get ready to
// start it
tlog := c.GetTestLog()
any := `(.|\n)*`
start := "^" + any
tail := any + "$"
c.Assert(tlog, gc.Matches, start+`using mongod: .*/mongod --version: "db version v2\.4\.9`+tail)
}
示例10: TestSucceedNow
func (s *FoundationS) TestSucceedNow(c *gocheck.C) {
defer (func() {
if c.Failed() {
c.Error("SucceedNow() didn't succeed the test")
}
if c.GetTestLog() != "" {
c.Error("Something got logged:\n" + c.GetTestLog())
}
})()
c.Fail()
c.SucceedNow()
c.Log("SucceedNow() didn't stop the test")
}
示例11: TestMinLogger
func (s *BootstrapS) TestMinLogger(c *gocheck.C) {
var logger minLogger
logger = log.New(os.Stderr, "", 0)
logger = c
logger.Output(0, "Hello there")
expected := "\\[LOG\\] [.0-9]+ Hello there\n"
output := c.GetTestLog()
matched, err := regexp.MatchString(expected, output)
if err != nil {
c.Error("Bad expression: ", expected)
} else if !matched {
c.Error("Output() didn't log properly:\n", output)
}
}
示例12: TestIgnoresUnpromisingNames
func (s *LocalRepoSuite) TestIgnoresUnpromisingNames(c *gc.C) {
err := ioutil.WriteFile(filepath.Join(s.seriesPath, "blah.notacharm"), nil, 0666)
c.Assert(err, gc.IsNil)
err = os.Mkdir(filepath.Join(s.seriesPath, ".blah"), 0666)
c.Assert(err, gc.IsNil)
renameSibling(c, s.addDir("dummy"), ".dummy")
renameSibling(c, s.addBundle("dummy"), "dummy.notacharm")
charmURL := charm.MustParseURL("local:quantal/dummy")
_, err = s.repo.Get(charmURL)
s.checkNotFoundErr(c, err, charmURL)
_, err = charm.Latest(s.repo, charmURL)
s.checkNotFoundErr(c, err, charmURL)
c.Assert(c.GetTestLog(), gc.Equals, "")
}
示例13: TestBundleToWithNonExecutableHooks
// Bug #864164: Must complain if charm hooks aren't executable
func (s *DirSuite) TestBundleToWithNonExecutableHooks(c *gc.C) {
hooks := []string{"install", "start", "config-changed", "upgrade-charm", "stop"}
for _, relName := range []string{"foo", "bar", "self"} {
for _, kind := range []string{"joined", "changed", "departed", "broken"} {
hooks = append(hooks, relName+"-relation-"+kind)
}
}
dir := charmtesting.Charms.Dir("all-hooks")
path := filepath.Join(c.MkDir(), "bundle.charm")
file, err := os.Create(path)
c.Assert(err, gc.IsNil)
err = dir.BundleTo(file)
file.Close()
c.Assert(err, gc.IsNil)
tlog := c.GetTestLog()
for _, hook := range hooks {
fullpath := filepath.Join(dir.Path, "hooks", hook)
exp := fmt.Sprintf(`^(.|\n)*WARNING juju.charm making "%s" executable in charm(.|\n)*$`, fullpath)
c.Assert(tlog, gc.Matches, exp, gc.Commentf("hook %q was not made executable", fullpath))
}
// Expand it and check the hooks' permissions
// (But do not use ExpandTo(), just use the raw zip)
f, err := os.Open(path)
c.Assert(err, gc.IsNil)
defer f.Close()
fi, err := f.Stat()
c.Assert(err, gc.IsNil)
size := fi.Size()
zipr, err := zip.NewReader(f, size)
c.Assert(err, gc.IsNil)
allhooks := dir.Meta().Hooks()
for _, zfile := range zipr.File {
cleanName := filepath.Clean(zfile.Name)
if strings.HasPrefix(cleanName, "hooks") {
hookName := filepath.Base(cleanName)
if _, ok := allhooks[hookName]; ok {
perms := zfile.Mode()
c.Assert(perms&0100 != 0, gc.Equals, true, gc.Commentf("hook %q is not executable", hookName))
}
}
}
}
示例14: TestErrorf
func (s *FoundationS) TestErrorf(c *gocheck.C) {
// Do not use checkState() here. It depends on Errorf() working.
expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
" c.Errorf(\"Error %%v!\", \"message\")\n"+
"... Error: Error message!\n\n",
getMyLine()+1)
c.Errorf("Error %v!", "message")
failed := c.Failed()
c.Succeed()
if log := c.GetTestLog(); log != expectedLog {
c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog)
c.Fail()
}
if !failed {
c.Logf("Errorf() didn't put the test in a failed state")
c.Fail()
}
}
示例15: TestFatalf
func (s *FoundationS) TestFatalf(c *gocheck.C) {
var line int
defer (func() {
if !c.Failed() {
c.Error("Fatalf() didn't fail the test")
} else {
c.Succeed()
expected := fmt.Sprintf("foundation_test.go:%d:\n"+
" c.Fatalf(\"Die %%s!\", \"now\")\n"+
"... Error: Die now!\n\n",
line)
if c.GetTestLog() != expected {
c.Error("Incorrect log:", c.GetTestLog())
}
}
})()
line = getMyLine() + 1
c.Fatalf("Die %s!", "now")
c.Log("Fatalf() didn't stop the test")
}