當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.GetTestLog方法代碼示例

本文整理匯總了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))
	}
}
開發者ID:kelsieflynn,項目名稱:gocheck,代碼行數:7,代碼來源:bootstrap_test.go

示例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)
}
開發者ID:kapilt,項目名稱:testing,代碼行數:32,代碼來源:log_test.go

示例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")
}
開發者ID:howbazaar,項目名稱:testing,代碼行數:7,代碼來源:log_test.go

示例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",
	)
}
開發者ID:howbazaar,項目名稱:testing,代碼行數:7,代碼來源:log_test.go

示例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"`)
}
開發者ID:kapilt,項目名稱:juju,代碼行數:8,代碼來源:lxc_test.go

示例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")
}
開發者ID:kapilt,項目名稱:juju,代碼行數:8,代碼來源:osversion_test.go

示例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)
}
開發者ID:kelsieflynn,項目名稱:gocheck,代碼行數:9,代碼來源:foundation_test.go

示例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)
}
開發者ID:bz2,項目名稱:charm,代碼行數:12,代碼來源:repo_test.go

示例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)
}
開發者ID:klyachin,項目名稱:juju,代碼行數:50,代碼來源:mongo_test.go

示例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")
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:14,代碼來源:foundation_test.go

示例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)
	}
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:14,代碼來源:foundation_test.go

示例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, "")
}
開發者ID:bz2,項目名稱:charm,代碼行數:15,代碼來源:repo_test.go

示例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))
			}
		}
	}
}
開發者ID:bz2,項目名稱:charm,代碼行數:46,代碼來源:dir_test.go

示例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()
	}
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:18,代碼來源:foundation_test.go

示例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")
}
開發者ID:evaluation-alex,項目名稱:gosync,代碼行數:21,代碼來源:foundation_test.go


注:本文中的launchpad/net/gocheck.C.GetTestLog方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。