当前位置: 首页>>代码示例>>Golang>>正文


Golang v1.Commentf函数代码示例

本文整理汇总了Golang中gopkg/in/check/v1.Commentf函数的典型用法代码示例。如果您正苦于以下问题:Golang Commentf函数的具体用法?Golang Commentf怎么用?Golang Commentf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Commentf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的gopkg/in/check/v1.Commentf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。