本文整理汇总了Golang中gopkg/in/check/v1.Commentf函数的典型用法代码示例。如果您正苦于以下问题:Golang Commentf函数的具体用法?Golang Commentf怎么用?Golang Commentf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Commentf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SetUpSuite
func (s *ConsulCatalogSuite) SetUpSuite(c *check.C) {
dockerHost := os.Getenv("DOCKER_HOST")
if dockerHost == "" {
// FIXME Handle windows -- see if dockerClient already handle that or not
dockerHost = fmt.Sprintf("unix://%s", opts.DefaultUnixSocket)
}
// Make sure we can speak to docker
dockerClient, err := docker.NewClient(dockerHost)
c.Assert(err, checker.IsNil, check.Commentf("Error connecting to docker daemon"))
s.dockerClient = dockerClient
s.createComposeProject(c, "consul_catalog")
err = s.composeProject.Up()
c.Assert(err, checker.IsNil, check.Commentf("Error starting project"))
consul, err := s.GetContainer("integration-test-consul_catalog_consul_1")
c.Assert(err, checker.IsNil, check.Commentf("Error finding consul container"))
s.consulIP = consul.NetworkSettings.IPAddress
config := api.DefaultConfig()
config.Address = s.consulIP + ":8500"
consulClient, err := api.NewClient(config)
if err != nil {
c.Fatalf("Error creating consul client")
}
s.consulClient = consulClient
// Wait for consul to elect itself leader
time.Sleep(2000 * time.Millisecond)
}
开发者ID:tayzlor,项目名称:traefik,代码行数:30,代码来源:consul_catalog_test.go
示例2: TestPrimaryKey
func (s *bakerySuite) TestPrimaryKey(c *gc.C) {
// Put some records in, with some duplicates. Exercises rollbacks.
c.Assert(s.storage.Put("foo", "bar"), gc.IsNil)
c.Assert(s.storage.Put("foo", "bar"), gc.NotNil)
c.Assert(s.storage.Put("foo", "bar"), gc.NotNil)
_, err := s.storage.Get("nope")
c.Assert(err, gc.NotNil)
c.Assert(s.storage.Put("baz", "quux"), gc.IsNil)
c.Assert(s.storage.Put("baz", "quux"), gc.NotNil)
c.Assert(s.storage.Put("a", "b"), gc.IsNil)
c.Assert(s.storage.Put("empty", ""), gc.IsNil)
for i, testCase := range []struct {
location, item string
}{{"foo", "bar"}, {"baz", "quux"}, {"a", "b"}, {"empty", ""}} {
comment := gc.Commentf("test#%d expect contents %#v", i, testCase)
item, err := s.storage.Get(testCase.location)
c.Assert(err, gc.IsNil, comment)
c.Assert(item, gc.Equals, testCase.item, comment)
}
for i, loc := range []string{"foo", "baz", "a", "empty"} {
comment := gc.Commentf("test#%d expect unique %s", i, loc)
var count int
row := s.db.QueryRow("SELECT COUNT(1) FROM bakery WHERE location = $1", loc)
c.Assert(row.Scan(&count), gc.IsNil, comment)
c.Assert(count, gc.Equals, 1, comment)
}
}
开发者ID:cmars,项目名称:oostore,代码行数:27,代码来源:bakery_test.go
示例3: SetUpSuite
func (s *DockerSuite) SetUpSuite(c *check.C) {
dockerHost := os.Getenv("DOCKER_HOST")
if dockerHost == "" {
// FIXME Handle windows -- see if dockerClient already handle that or not
dockerHost = fmt.Sprintf("unix://%s", opts.DefaultUnixSocket)
}
// Make sure we can speak to docker
dockerClient, err := docker.NewClient(dockerHost)
c.Assert(err, checker.IsNil, check.Commentf("Error connecting to docker daemon"))
s.client = dockerClient
c.Assert(s.client.Ping(), checker.IsNil)
// Pull required images
for repository, tag := range RequiredImages {
image := fmt.Sprintf("%s:%s", repository, tag)
_, err := s.client.InspectImage(image)
if err != nil {
if err != docker.ErrNoSuchImage {
c.Fatalf("Error while inspect image %s", image)
}
err = s.client.PullImage(docker.PullImageOptions{
Repository: repository,
Tag: tag,
}, docker.AuthConfiguration{})
c.Assert(err, checker.IsNil, check.Commentf("Error while pulling image %s", image))
}
}
}
开发者ID:abhishekamralkar,项目名称:traefik,代码行数:29,代码来源:docker_test.go
示例4: TestPrimaryKey
func (s *objectSuite) TestPrimaryKey(c *gc.C) {
// Put some records in, with some duplicates. Exercises rollbacks.
c.Assert(s.storage.Put("foo", []byte("bar"), "bar-ish"), gc.IsNil)
c.Assert(s.storage.Put("foo", []byte("bar"), "bar-ish"), gc.NotNil)
c.Assert(s.storage.Put("foo", []byte("bar"), "bar-ish"), gc.NotNil)
_, _, err := s.storage.Get("nope")
c.Assert(err, gc.NotNil)
c.Assert(s.storage.Put("baz", []byte("quux"), "quux-ish"), gc.IsNil)
c.Assert(s.storage.Put("baz", []byte("quux"), "quux-ish"), gc.NotNil)
c.Assert(s.storage.Put("a", []byte("b"), ""), gc.IsNil)
c.Assert(s.storage.Put("empty", []byte(""), "nothing-ness"), gc.IsNil)
for i, testCase := range []struct {
id, contents, contentType string
}{{"foo", "bar", "bar-ish"}, {"baz", "quux", "quux-ish"}, {"a", "b", ""}, {"empty", "", "nothing-ness"}} {
comment := gc.Commentf("test#%d expect contents %#v", i, testCase)
content, contentType, err := s.storage.Get(testCase.id)
c.Assert(err, gc.IsNil, comment)
c.Assert(content, gc.DeepEquals, []byte(testCase.contents), comment)
c.Assert(contentType, gc.Equals, testCase.contentType, comment)
}
for i, id := range []string{"foo", "baz", "a", "empty"} {
comment := gc.Commentf("test#%d expect unique %s", i, id)
var count int
row := s.db.QueryRow("SELECT COUNT(1) FROM object WHERE id = $1", id)
c.Assert(row.Scan(&count), gc.IsNil, comment)
c.Assert(count, gc.Equals, 1, comment)
}
}
开发者ID:cmars,项目名称:oostore,代码行数:28,代码来源:object_test.go
示例5: TestSingleService
func (s *ConsulCatalogSuite) TestSingleService(c *check.C) {
cmd := exec.Command(traefikBinary, "--consulCatalog", "--consulCatalog.endpoint="+s.consulIP+":8500", "--consulCatalog.domain=consul.localhost", "--configFile=fixtures/consul_catalog/simple.toml")
err := cmd.Start()
c.Assert(err, checker.IsNil)
defer cmd.Process.Kill()
nginx, err := s.GetContainer("integration-test-consul_catalog_nginx_1")
c.Assert(err, checker.IsNil, check.Commentf("Error finding nginx container"))
err = s.registerService("test", nginx.NetworkSettings.IPAddress, 80)
c.Assert(err, checker.IsNil, check.Commentf("Error registering service"))
defer s.deregisterService("test", nginx.NetworkSettings.IPAddress)
time.Sleep(5000 * time.Millisecond)
client := &http.Client{}
req, err := http.NewRequest("GET", "http://127.0.0.1:8000/", nil)
c.Assert(err, checker.IsNil)
req.Host = "test.consul.localhost"
resp, err := client.Do(req)
c.Assert(err, checker.IsNil)
c.Assert(resp.StatusCode, checker.Equals, 200)
_, err = ioutil.ReadAll(resp.Body)
c.Assert(err, checker.IsNil)
}
开发者ID:tayzlor,项目名称:traefik,代码行数:26,代码来源:consul_catalog_test.go
示例6: TestRequestMustAppendParamsToURL
func (s *APIv2Suite) TestRequestMustAppendParamsToURL(c *check.C) {
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c.Check(r.URL.Query()["test-param1"], check.DeepEquals, []string{"test-value1"},
check.Commentf("Wrong param value"))
c.Check(r.URL.Query()["test-param2"], check.DeepEquals, []string{"test-value2"},
check.Commentf("Wrong param value"))
io.WriteString(w, "{}")
}))
c.Assert(mockServer, check.NotNil, check.Commentf("Error creating mock server"))
defer mockServer.Close()
mockServerURL, err := url.Parse(mockServer.URL)
c.Assert(err, check.IsNil, check.Commentf("Error parsing URL: %s", err))
client := NewClient("test-id")
client.URL = *mockServerURL
var r interface{}
params := url.Values{
"test-param1": {"test-value1"},
"test-param2": {"test-value2"},
}
err = client.Request("dummy-method", "test-path", params, &r)
c.Assert(err, check.IsNil, check.Commentf("Error on request: %s", err))
}
开发者ID:JaquerEspeis,项目名称:mapillary,代码行数:27,代码来源:api_test.go
示例7: TestRequestMustReturnJSON
func (s *APIv2Suite) TestRequestMustReturnJSON(c *check.C) {
testJSON := map[string]interface{}{
"test-param1": "test-value1",
"test-param2": "test-value2",
}
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
b, err := json.Marshal(testJSON)
c.Assert(err, check.IsNil, check.Commentf("Error encoding the JSON: %s", err))
w.Header().Set("Content-Type", "application/json")
w.Write(b)
}))
c.Assert(mockServer, check.NotNil, check.Commentf("Error creating mock server"))
defer mockServer.Close()
mockServerURL, err := url.Parse(mockServer.URL)
c.Assert(err, check.IsNil, check.Commentf("Error parsing URL: %s", err))
client := NewClient("test-id")
client.URL = *mockServerURL
var r interface{}
params := url.Values{
"test-param1": {"test-value1"},
"test-param2": {"test-value2"},
}
err = client.Request("dummy-method", "test-path", params, &r)
c.Assert(err, check.IsNil, check.Commentf("Error on request: %s", err))
c.Assert(r, check.DeepEquals, testJSON)
}
开发者ID:JaquerEspeis,项目名称:mapillary,代码行数:31,代码来源:api_test.go
示例8: TestMachineAgentSymlinkJujuRunExists
func (s *MachineSuite) TestMachineAgentSymlinkJujuRunExists(c *gc.C) {
if runtime.GOOS == "windows" {
// Cannot make symlink to nonexistent file on windows or
// create a file point a symlink to it then remove it
c.Skip("Cannot test this on windows")
}
stm, _, _ := s.primeAgent(c, state.JobManageModel)
a := s.newAgent(c, stm)
defer a.Stop()
// Pre-create the symlinks, but pointing to the incorrect location.
links := []string{jujuRun, jujuDumpLogs}
a.rootDir = c.MkDir()
for _, link := range links {
fullLink := utils.EnsureBaseDir(a.rootDir, link)
c.Assert(os.MkdirAll(filepath.Dir(fullLink), os.FileMode(0755)), jc.ErrorIsNil)
c.Assert(symlink.New("/nowhere/special", fullLink), jc.ErrorIsNil, gc.Commentf(link))
}
// Start the agent and wait for it be running.
_, done := s.waitForOpenState(c, a)
// juju-run symlink should have been recreated.
for _, link := range links {
fullLink := utils.EnsureBaseDir(a.rootDir, link)
linkTarget, err := symlink.Read(fullLink)
c.Assert(err, jc.ErrorIsNil)
c.Assert(linkTarget, gc.Not(gc.Equals), "/nowhere/special", gc.Commentf(link))
}
s.waitStopped(c, state.JobManageModel, a, done)
}
开发者ID:bac,项目名称:juju,代码行数:33,代码来源:machine_test.go
示例9: TestWithoutFlagsPacketMustNotSetAnyPresentFlag
func (s *SubunitSuite) TestWithoutFlagsPacketMustNotSetAnyPresentFlag(c *check.C) {
s.stream.Status(subunit.Event{})
s.output.Next(1) // skip the signature
flags := s.output.Next(2)
flagsHighByte := flags[0] & 0xf // Remove the version, 4 first bits.
flagsLowByte := flags[1]
c.Check(flagsHighByte, check.Equals, uint8(0x0), check.Commentf("Wrong flags high byte"))
c.Check(flagsLowByte, check.Equals, uint8(0x0), check.Commentf("Wrong flags low byte"))
}
开发者ID:elopio,项目名称:subunit-go,代码行数:9,代码来源:subunit_test.go
示例10: TestParserReporterReturnsTheNumberOfBytesWritten
func (s *ParserReportSuite) TestParserReporterReturnsTheNumberOfBytesWritten(c *check.C) {
actual, err := s.subject.Write([]byte(fmt.Sprintf("****** Running %s\n", s.testID)))
c.Assert(err, check.IsNil, check.Commentf("Error while writing to output %s", err))
expected := len([]byte(fmt.Sprintf("test: %s\n", s.testID)))
c.Assert(actual, check.Equals, expected,
check.Commentf("Expected length output %d not found, actual %d",
expected, actual))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:10,代码来源:parser_test.go
示例11: TestOS
func (s *CommonSuite) TestOS(c *checker.C) {
expwin := (os.PathSeparator == '\\' && os.PathListSeparator == ';')
res := IsWindows()
if !expwin {
c.Assert(res, checker.Equals, expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
} else {
c.Assert(res, checker.Not(checker.Equals), expwin, checker.Commentf("IsWindows is", res, "but path is", os.PathSeparator))
}
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:10,代码来源:path_test.go
示例12: SetUpSuite
func (s *PGSuite) SetUpSuite(c *gc.C) {
s.initdbDir = c.MkDir()
out, err := exec.Command("pg_config", "--bindir").Output()
c.Assert(err, gc.IsNil, gc.Commentf("pg_config"))
bindir := string(bytes.TrimSpace(out))
s.postgres = filepath.Join(bindir, "postgres")
initdb := filepath.Join(bindir, "initdb")
err = exec.Command(initdb, "-D", s.initdbDir).Run()
c.Assert(err, gc.IsNil, gc.Commentf("initdb"))
}
开发者ID:cmars,项目名称:pgtest,代码行数:11,代码来源:pgtest.go
示例13: TestFileReporterReturnsTheNumberOfBytesWritten
func (s *FileReportSuite) TestFileReporterReturnsTheNumberOfBytesWritten(c *check.C) {
testData := "Test data"
actual, err := s.subject.Write([]byte(testData))
c.Assert(err, check.IsNil, check.Commentf("Error while writing to output %s", err))
expected := len([]byte(testData))
c.Assert(actual, check.Equals, expected,
check.Commentf("Expected length output %d not found, actual %d",
expected, actual))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:11,代码来源:file_test.go
示例14: clientID
func clientID(c *check.C) string {
confFile, err := os.Open("conf.json")
c.Assert(err, check.IsNil, check.Commentf("Error opening conf file: %s", err))
defer confFile.Close()
var config conf
confFileContents, err := ioutil.ReadAll(confFile)
c.Assert(err, check.IsNil, check.Commentf("Error reading the conf file: %s", err))
err = json.Unmarshal(confFileContents, &config)
c.Assert(err, check.IsNil, check.Commentf("Error unmarshaling JSON config: %s", err))
return config.ClientID
}
开发者ID:JaquerEspeis,项目名称:mapillary,代码行数:11,代码来源:search_test.go
示例15: TestPacketMIME
func (s *SubunitSuite) TestPacketMIME(c *check.C) {
testMIME := "text/plain;charset=utf8"
s.stream.Status(subunit.Event{MIME: testMIME})
// skip the signature (1 byte) and the flags (2 bytes)
s.output.Next(3)
// skip the packet length (variable size)
s.readNumber()
idLen := s.readNumber()
c.Check(idLen, check.Equals, len(testMIME), check.Commentf("Wrong length"))
mime := string(s.output.Next(idLen))
c.Check(mime, check.Equals, testMIME, check.Commentf("Wrong ID"))
}
开发者ID:elopio,项目名称:subunit-go,代码行数:12,代码来源:subunit_test.go
示例16: TestFileReporterWritesGivenData
func (s *FileReportSuite) TestFileReporterWritesGivenData(c *check.C) {
s.subject.Write([]byte("Test"))
content, err := ioutil.ReadFile(s.path)
c.Assert(err, check.IsNil,
check.Commentf("Error reading file %s, %s", s.path, err))
c.Assert(string(content), check.Equals, "Test",
check.Commentf("Expected content '%s' not found, actual '%s'",
"Test", string(content)))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:12,代码来源:file_test.go
示例17: TestFileReporterDoNotRecreateOutputFile
func (s *FileReportSuite) TestFileReporterDoNotRecreateOutputFile(c *check.C) {
s.subject.Write([]byte("Start"))
s.subject.Write([]byte("-End"))
content, err := ioutil.ReadFile(s.path)
c.Assert(err, check.IsNil,
check.Commentf("Obtained error while reading file %s, %s", s.path, err))
c.Assert(string(content), check.Equals, "Start-End",
check.Commentf("Not found appended data in output file! content %s, not found %s",
string(content), "Start-End"))
}
开发者ID:pombredanne,项目名称:snappy-1,代码行数:12,代码来源:file_test.go
示例18: TestStartStop
// TestStartStop is similar to Tests.TestStartStop except
// that it does not assume a pristine environment.
func (t *LiveTests) TestStartStop(c *gc.C) {
t.BootstrapOnce(c)
inst, _ := jujutesting.AssertStartInstance(c, t.Env, "0")
c.Assert(inst, gc.NotNil)
id0 := inst.Id()
insts, err := t.Env.Instances([]instance.Id{id0, id0})
c.Assert(err, jc.ErrorIsNil)
c.Assert(insts, gc.HasLen, 2)
c.Assert(insts[0].Id(), gc.Equals, id0)
c.Assert(insts[1].Id(), gc.Equals, id0)
// Asserting on the return of AllInstances makes the test fragile,
// as even comparing the before and after start values can be thrown
// off if other instances have been created or destroyed in the same
// time frame. Instead, just check the instance we created exists.
insts, err = t.Env.AllInstances()
c.Assert(err, jc.ErrorIsNil)
found := false
for _, inst := range insts {
if inst.Id() == id0 {
c.Assert(found, gc.Equals, false, gc.Commentf("%v", insts))
found = true
}
}
c.Assert(found, gc.Equals, true, gc.Commentf("expected %v in %v", inst, insts))
addresses, err := jujutesting.WaitInstanceAddresses(t.Env, inst.Id())
c.Assert(err, jc.ErrorIsNil)
c.Assert(addresses, gc.Not(gc.HasLen), 0)
insts, err = t.Env.Instances([]instance.Id{id0, ""})
c.Assert(err, gc.Equals, environs.ErrPartialInstances)
c.Assert(insts, gc.HasLen, 2)
c.Check(insts[0].Id(), gc.Equals, id0)
c.Check(insts[1], gc.IsNil)
err = t.Env.StopInstances(inst.Id())
c.Assert(err, jc.ErrorIsNil)
// The machine may not be marked as shutting down
// immediately. Repeat a few times to ensure we get the error.
for a := t.Attempt.Start(); a.Next(); {
insts, err = t.Env.Instances([]instance.Id{id0})
if err != nil {
break
}
}
c.Assert(err, gc.Equals, environs.ErrNoInstances)
c.Assert(insts, gc.HasLen, 0)
}
开发者ID:Pankov404,项目名称:juju,代码行数:54,代码来源:livetests.go
示例19: TestAddCharmConcurrently
func (s *serviceSuite) TestAddCharmConcurrently(c *gc.C) {
var putBarrier sync.WaitGroup
var blobs blobs
s.PatchValue(service.NewStateStorage, func(uuid string, session *mgo.Session) statestorage.Storage {
storage := statestorage.NewStorage(uuid, session)
return &recordingStorage{Storage: storage, blobs: &blobs, putBarrier: &putBarrier}
})
client := s.APIState.Client()
curl, _ := s.UploadCharm(c, "trusty/wordpress-3", "wordpress")
// Try adding the same charm concurrently from multiple goroutines
// to test no "duplicate key errors" are reported (see lp bug
// #1067979) and also at the end only one charm document is
// created.
var wg sync.WaitGroup
// We don't add them 1-by-1 because that would allow each goroutine to
// finish separately without actually synchronizing between them
putBarrier.Add(10)
for i := 0; i < 10; i++ {
wg.Add(1)
go func(index int) {
defer wg.Done()
c.Assert(client.AddCharm(curl), gc.IsNil, gc.Commentf("goroutine %d", index))
sch, err := s.State.Charm(curl)
c.Assert(err, gc.IsNil, gc.Commentf("goroutine %d", index))
c.Assert(sch.URL(), jc.DeepEquals, curl, gc.Commentf("goroutine %d", index))
}(i)
}
wg.Wait()
blobs.Lock()
c.Assert(blobs.m, gc.HasLen, 10)
// Verify there is only a single uploaded charm remains and it
// contains the correct data.
sch, err := s.State.Charm(curl)
c.Assert(err, jc.ErrorIsNil)
storagePath := sch.StoragePath()
c.Assert(blobs.m[storagePath], jc.IsTrue)
for path, exists := range blobs.m {
if path != storagePath {
c.Assert(exists, jc.IsFalse)
}
}
storage := statestorage.NewStorage(s.State.EnvironUUID(), s.State.MongoSession())
s.assertUploaded(c, storage, sch.StoragePath(), sch.BundleSha256())
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:52,代码来源:service_test.go
示例20: CheckDone
// CheckDone asserts that all the expected prompts
// have been printed and all the replies read, and
// reports whether the check succeeded.
func (p *SeqPrompter) CheckDone() bool {
if p.failed {
// No point in doing the details checks if
// a prompt failed earlier - it just makes
// the resulting test failure noisy.
p.c.Errorf("prompter has failed")
return false
}
r := p.c.Check(p.ios, gc.HasLen, 0, gc.Commentf("unused prompts"))
r = p.c.Check(p.HasUnread(), gc.Equals, false, gc.Commentf("some input was not read")) && r
r = p.c.Check(p.Tail(), gc.Matches, p.finalText, gc.Commentf("final text mismatch")) && r
return r
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:prompt.go
注:本文中的gopkg/in/check/v1.Commentf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论