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


Golang C.Fail方法代码示例

本文整理汇总了Golang中launchpad/net/gocheck.C.Fail方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Fail方法的具体用法?Golang C.Fail怎么用?Golang C.Fail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在launchpad/net/gocheck.C的用法示例。


在下文中一共展示了C.Fail方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: startReading

// startReading starts a goroutine receiving the lines out of the reader
// in the background and passing them to a created string channel. This
// will used in the assertions.
func startReading(c *gc.C, tailer *tailer.Tailer, reader *io.PipeReader, writer *io.PipeWriter) chan string {
	linec := make(chan string)
	// Start goroutine for reading.
	go func() {
		defer close(linec)
		reader := bufio.NewReader(reader)
		for {
			line, err := reader.ReadString('\n')
			switch err {
			case nil:
				linec <- line
			case io.EOF:
				return
			default:
				c.Fail()
			}
		}
	}()
	// Close writer when tailer is stopped or has an error. Tailer using
	// components can do it the same way.
	go func() {
		tailer.Wait()
		writer.Close()
	}()
	return linec
}
开发者ID:jameinel,项目名称:core,代码行数:29,代码来源:tailer_test.go

示例2: TestFailedAndSucceed

func (s *BootstrapS) TestFailedAndSucceed(c *gocheck.C) {
	c.Fail()
	c.Succeed()
	if c.Failed() {
		critical("c.Succeed() didn't put the test back in a non-failed state")
	}
}
开发者ID:kelsieflynn,项目名称:gocheck,代码行数:7,代码来源:bootstrap_test.go

示例3: checkToolsContent

func checkToolsContent(c *gc.C, data []byte, uploaded string) {
	zr, err := gzip.NewReader(bytes.NewReader(data))
	c.Check(err, gc.IsNil)
	defer zr.Close()
	tr := tar.NewReader(zr)
	found := false
	for {
		hdr, err := tr.Next()
		if err == io.EOF {
			break
		}
		c.Check(err, gc.IsNil)
		if strings.ContainsAny(hdr.Name, "/\\") {
			c.Fail()
		}
		if hdr.Typeflag != tar.TypeReg {
			c.Fail()
		}
		content, err := ioutil.ReadAll(tr)
		c.Check(err, gc.IsNil)
		c.Check(string(content), gc.Equals, uploaded)
		found = true
	}
	c.Check(found, jc.IsTrue)
}
开发者ID:rogpeppe,项目名称:juju,代码行数:25,代码来源:upgradejuju_test.go

示例4: TestLongContainerName

func (s *IntegrationTestSuite) TestLongContainerName(c *chk.C) {
	id, err := containers.NewIdentifier("IntTest006xxxxxxxxxxxxxx")
	c.Assert(err, chk.IsNil)
	s.containerIds = append(s.containerIds, id)

	hostContainerId := fmt.Sprintf("%v/%v", s.daemonURI, id)

	cmd := exec.Command("/usr/bin/gear", "install", TestImage, hostContainerId, "--start", "--ports=8080:4003", "--isolate")
	data, err := cmd.CombinedOutput()
	c.Log(string(data))
	c.Assert(err, chk.IsNil)
	s.assertContainerState(c, id, CONTAINER_STARTED)

	s.assertFilePresent(c, id.UnitPathFor(), 0664, true)
	s.assertFilePresent(c, filepath.Join(id.HomePath(), "container-init.sh"), 0700, false)

	ports, err := containers.GetExistingPorts(id)
	c.Assert(err, chk.IsNil)
	c.Assert(len(ports), chk.Equals, 1)

	t := time.NewTicker(time.Second / 10)
	defer t.Stop()
	select {
	case <-t.C:
		resp, err := http.Get(fmt.Sprintf("http://0.0.0.0:%v", ports[0].External))
		if err == nil {
			c.Assert(resp.StatusCode, chk.Equals, 200)
		}
	case <-time.After(time.Second * 15):
		c.Fail()
	}
}
开发者ID:roacobb,项目名称:geard,代码行数:32,代码来源:integration_test.go

示例5: TestFailedAndFail

func (s *BootstrapS) TestFailedAndFail(c *gocheck.C) {
	if c.Failed() {
		critical("c.Failed() must be false first!")
	}
	c.Fail()
	if !c.Failed() {
		critical("c.Fail() didn't put the test in a failed state!")
	}
	c.Succeed()
}
开发者ID:kelsieflynn,项目名称:gocheck,代码行数:10,代码来源:bootstrap_test.go

示例6: 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

示例7: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_service_test")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.user = &auth.User{Email: "[email protected]"}
	err = s.user.Create()
	c.Assert(err, gocheck.IsNil)
	s.team = &auth.Team{Name: "Raul", Users: []string{s.user.Email}}
	err = s.conn.Teams().Insert(s.team)
	c.Assert(err, gocheck.IsNil)
	if err != nil {
		c.Fail()
	}
}
开发者ID:rualatngua,项目名称:tsuru,代码行数:16,代码来源:suite_test.go

示例8: 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

示例9: SetUpTest

func (sts *SettingTestSuite) SetUpTest(c *C.C) {
	var err error
	core := NewMockSettingCore()
	sts.s, err = NewSetting(core)

	sts.CategoryDisplayModeChangedCount = 0
	sts.s.CategoryDisplayModeChanged = func(int64) {
		sts.CategoryDisplayModeChangedCount++
	}

	sts.SortMethodChangedCount = 0
	sts.s.SortMethodChanged = func(int64) {
		sts.SortMethodChangedCount++
	}
	if err != nil {
		c.Fail()
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:18,代码来源:setting_test.go

示例10: TestPinYin

func (self *PinYinTestSuite) TestPinYin(c *C.C) {
	names := []string{}
	oldLang := os.Getenv("LANGUAGE")
	os.Setenv("LANGUAGE", "zh_CN.UTF-8")
	addName := func(m *[]string, n string) {
		app := gio.NewDesktopAppInfoFromFilename(n)
		if app == nil {
			c.Skip("create desktop app info failed")
			return
		}
		defer app.Unref()
		name := app.GetDisplayName()
		c.Logf("add %q to names", name)
		*m = append(*m, name)
	}
	addName(&names, path.Join(self.testDataDir, "deepin-software-center.desktop"))
	addName(&names, path.Join(self.testDataDir, "firefox.desktop"))
	tree, err := NewPinYinSearchAdapter(names)
	if err != nil {
		c.Log(err)
		c.Fail()
	}
	search := func(key string, res []string) {
		keys, err := tree.Search(key)
		if err != nil {
			c.Log(err)
			c.Fail()
			return
		}
		c.Assert(keys, C.DeepEquals, res)
	}
	search("shang", []string{"深度商店"})
	search("sd", []string{"深度商店"})
	search("商店", []string{"深度商店"})
	search("firefox", []string{"Firefox 网络浏览器"})
	search("wang", []string{"Firefox 网络浏览器"})
	search("网络", []string{"Firefox 网络浏览器"})

	os.Setenv("LANGUAGE", oldLang)
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:40,代码来源:pinyin_adapter_test.go

示例11: TestShareEnvironmentThreeUsers

func (s *clientSuite) TestShareEnvironmentThreeUsers(c *gc.C) {
	client := s.APIState.Client()
	existingUser := s.Factory.MakeEnvUser(c, nil)
	localUser := s.Factory.MakeUser(c, nil)
	newUserTag := names.NewUserTag("[email protected]")
	cleanup := api.PatchClientFacadeCall(client,
		func(request string, paramsIn interface{}, response interface{}) error {
			if users, ok := paramsIn.(params.ModifyEnvironUsers); ok {
				c.Assert(users.Changes, gc.HasLen, 3)
				c.Logf(string(users.Changes[0].Action), gc.Equals, string(params.AddEnvUser))
				c.Logf(users.Changes[0].UserTag, gc.Equals, existingUser.UserTag().String())
				c.Logf(string(users.Changes[1].Action), gc.Equals, string(params.AddEnvUser))
				c.Logf(users.Changes[1].UserTag, gc.Equals, localUser.UserTag().String())
				c.Logf(string(users.Changes[1].Action), gc.Equals, string(params.AddEnvUser))
				c.Logf(users.Changes[1].UserTag, gc.Equals, newUserTag.String())
			} else {
				c.Log("wrong input structure")
				c.Fail()
			}
			if result, ok := response.(*params.ErrorResults); ok {
				err := &params.Error{Message: "failed to create environment user: env user already exists"}
				*result = params.ErrorResults{Results: []params.ErrorResult{{Error: err}, {Error: nil}, {Error: nil}}}
			} else {
				c.Log("wrong output structure")
				c.Fail()
			}
			return nil
		},
	)
	defer cleanup()

	result, err := client.ShareEnvironment([]names.UserTag{existingUser.UserTag(), localUser.UserTag(), newUserTag})
	c.Assert(err, gc.IsNil)
	c.Assert(result.Results, gc.HasLen, 3)
	c.Assert(result.Results[0].Error, gc.ErrorMatches, `failed to create environment user: env user already exists`)
	c.Assert(result.Results[1].Error, gc.IsNil)
	c.Assert(result.Results[2].Error, gc.IsNil)
}
开发者ID:zhouqt,项目名称:juju,代码行数:38,代码来源:client_test.go

示例12: TestLogAndFail

func (s *FailHelper) TestLogAndFail(c *gocheck.C) {
	s.testLine = getMyLine() - 1
	c.Log("Expected failure!")
	c.Fail()
}
开发者ID:CloudMarc,项目名称:mgo,代码行数:5,代码来源:gocheck_test.go


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