本文整理汇总了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
}
示例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")
}
}
示例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)
}
示例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()
}
}
示例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()
}
示例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")
}
示例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()
}
}
示例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()
}
}
示例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()
}
}
示例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)
}
示例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 := ¶ms.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)
}
示例12: TestLogAndFail
func (s *FailHelper) TestLogAndFail(c *gocheck.C) {
s.testLine = getMyLine() - 1
c.Log("Expected failure!")
c.Fail()
}