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


Golang C.Fail方法代码示例

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


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

示例1: TestUpdateToolsAvailabilityNoMatches

func (s *AgentToolsSuite) TestUpdateToolsAvailabilityNoMatches(c *gc.C) {
	fakeNewEnvirons := func(*config.Config) (environs.Environ, error) {
		return dummyEnviron{}, nil
	}
	s.PatchValue(&newEnvirons, fakeNewEnvirons)

	fakeEnvConfig := func(_ *state.Model) (*config.Config, error) {
		sConfig := coretesting.FakeConfig()
		sConfig = sConfig.Merge(coretesting.Attrs{
			"agent-version": "2.5.0",
		})
		return config.New(config.NoDefaults, sConfig)
	}
	s.PatchValue(&envConfig, fakeEnvConfig)

	// No new tools available.
	fakeToolFinder := func(_ environs.Environ, _ int, _ int, _ string, _ coretools.Filter) (coretools.List, error) {
		return nil, errors.NotFoundf("tools")
	}

	// Update should never be called.
	fakeUpdate := func(_ *state.Model, v version.Number) error {
		c.Fail()
		return nil
	}

	err := updateToolsAvailability(&modelGetter{}, fakeToolFinder, fakeUpdate)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:29,代码来源:agenttools_test.go

示例2: TestClientModelUsers

func (s *clientSuite) TestClientModelUsers(c *gc.C) {
	client := s.APIState.Client()
	cleanup := api.PatchClientFacadeCall(client,
		func(request string, paramsIn interface{}, response interface{}) error {
			c.Assert(paramsIn, gc.IsNil)
			if response, ok := response.(*params.ModelUserInfoResults); ok {
				response.Results = []params.ModelUserInfoResult{
					{Result: &params.ModelUserInfo{UserName: "one"}},
					{Result: &params.ModelUserInfo{UserName: "two"}},
					{Result: &params.ModelUserInfo{UserName: "three"}},
				}
			} else {
				c.Log("wrong output structure")
				c.Fail()
			}
			return nil
		},
	)
	defer cleanup()

	obtained, err := client.ModelUserInfo()
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(obtained, jc.DeepEquals, []params.ModelUserInfo{
		{UserName: "one"},
		{UserName: "two"},
		{UserName: "three"},
	})
}
开发者ID:kat-co,项目名称:juju,代码行数:29,代码来源:client_test.go

示例3: TestFailedRestoreReboostrapMaintainsControllerInfo

func (s *restoreSuite) TestFailedRestoreReboostrapMaintainsControllerInfo(c *gc.C) {
	metadata := params.BackupsMetadataResult{
		CACert:       testing.CACert,
		CAPrivateKey: testing.CAKey,
	}
	s.command = backups.NewRestoreCommandForTest(
		s.store, &mockRestoreAPI{},
		func(string) (backups.ArchiveReader, *params.BackupsMetadataResult, error) {
			return &mockArchiveReader{}, &metadata, nil
		},
		nil,
		backups.GetRebootstrapParamsFuncWithError(),
	)
	s.PatchValue(&backups.BootstrapFunc, func(ctx environs.BootstrapContext, environ environs.Environ, args bootstrap.BootstrapParams) error {
		// We should not call bootstrap.
		c.Fail()
		return nil
	})

	_, err := testing.RunCommand(c, s.command, "restore", "-m", "testing:test1", "--file", "afile", "-b")
	c.Assert(err, gc.ErrorMatches, "failed")
	// The details below are as per what was done in test setup, so no changes.
	c.Assert(s.store.Controllers["testing"], jc.DeepEquals, jujuclient.ControllerDetails{
		Cloud:                  "mycloud",
		CloudRegion:            "a-region",
		CACert:                 testing.CACert,
		ControllerUUID:         "deadbeef-0bad-400d-8000-5b1d0d06f00d",
		APIEndpoints:           []string{"10.0.1.1:17777"},
		UnresolvedAPIEndpoints: []string{"10.0.1.1:17777"},
	})
}
开发者ID:bac,项目名称:juju,代码行数:31,代码来源:restore_test.go

示例4: mockAPICaller

func mockAPICaller(c *gc.C, callNumber *int32, apiCalls ...apiCall) apitesting.APICallerFunc {
	apiCaller := apitesting.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
		switch objType {
		case "NotifyWatcher":
			return nil
		case "Uniter":
			index := int(atomic.AddInt32(callNumber, 1)) - 1
			c.Check(index < len(apiCalls), jc.IsTrue)
			call := apiCalls[index]
			c.Logf("request %d, %s", index, request)
			c.Check(version, gc.Equals, 4)
			c.Check(id, gc.Equals, "")
			c.Check(request, gc.Equals, call.request)
			c.Check(arg, jc.DeepEquals, call.args)
			if call.err != nil {
				return common.ServerError(call.err)
			}
			testing.PatchValue(result, call.result)
		default:
			c.Fail()
		}
		return nil
	})
	return apiCaller
}
开发者ID:kat-co,项目名称:juju,代码行数:25,代码来源:relations_test.go

示例5: checkToolsContent

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

示例6: 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:kat-co,项目名称:utils,代码行数:29,代码来源:tailer_test.go

示例7: TestUnshareEnvironmentThreeUsers

func (s *clientSuite) TestUnshareEnvironmentThreeUsers(c *gc.C) {
	client := s.APIState.Client()
	missingUser := 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.Assert(string(users.Changes[0].Action), gc.Equals, string(params.RemoveEnvUser))
				c.Assert(users.Changes[0].UserTag, gc.Equals, missingUser.UserTag().String())
				c.Assert(string(users.Changes[1].Action), gc.Equals, string(params.RemoveEnvUser))
				c.Assert(users.Changes[1].UserTag, gc.Equals, localUser.UserTag().String())
				c.Assert(string(users.Changes[2].Action), gc.Equals, string(params.RemoveEnvUser))
				c.Assert(users.Changes[2].UserTag, gc.Equals, newUserTag.String())
			} else {
				c.Log("wrong input structure")
				c.Fail()
			}
			if result, ok := response.(*params.ErrorResults); ok {
				err := &params.Error{Message: "error unsharing user"}
				*result = params.ErrorResults{Results: []params.ErrorResult{{Error: err}, {Error: nil}, {Error: nil}}}
			} else {
				c.Log("wrong output structure")
				c.Fail()
			}
			return nil
		},
	)
	defer cleanup()

	err := client.UnshareEnvironment(missingUser.UserTag(), localUser.UserTag(), newUserTag)
	c.Assert(err, gc.ErrorMatches, "error unsharing user")
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:34,代码来源:client_test.go

示例8: expectUpgradeChannelNotClosed

func (s *UpgraderSuite) expectUpgradeChannelNotClosed(c *gc.C) {
	select {
	case <-s.agentUpgradeComplete:
		c.Fail()
	default:
	}
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:7,代码来源:upgrader_test.go

示例9: TestAid

func (s *UnitSuite) TestAid(t *check.C) {
	host, err := os.Hostname()
	if err != nil {
		host = _HOST
	}
	a := NewAid()
	if a.Generate() != host+"-1" {
		t.Fail()
	}
}
开发者ID:vyachin,项目名称:gami,代码行数:10,代码来源:gami_test.go

示例10: TestMismatchedP

func (s *ZpSuite) TestMismatchedP(c *gc.C) {
	defer func() {
		r := recover()
		c.Assert(r, gc.NotNil)
	}()
	a := zp5(1)
	b := Zi(p(65537), 9)
	a.Add(a, b)
	c.Fail()
}
开发者ID:cmars,项目名称:conflux,代码行数:10,代码来源:zp_test.go

示例11: TestRedirect

func (i *IntegrationSuite) TestRedirect(c *check.C) {
	ch := make(chan Message)
	check := func(m Message) {
		ch <- m
	}
	a.Redirect("sip/1234", "new", "1000", "1", &check)
	r := <-ch
	if r["Response"] != "Error" {
		c.Fail()
	}
}
开发者ID:vyachin,项目名称:gami,代码行数:11,代码来源:gami_test.go

示例12: TestOriginate

func (i *IntegrationSuite) TestOriginate(c *check.C) {
	o := NewOriginateApp("sip/1234", "playback", "hello-world")
	ch := make(chan Message)
	check := func(m Message) {
		ch <- m
	}
	a.Originate(o, nil, &check)
	r := <-ch
	if r["Response"] != "Error" {
		c.Fail()
	}
}
开发者ID:vyachin,项目名称:gami,代码行数:12,代码来源:gami_test.go

示例13: assertRsyslogConfigContents

func (s *syslogConfigSuite) assertRsyslogConfigContents(c *gc.C, slConfig *syslog.SyslogConfig, expectedConf string) {
	data, err := slConfig.Render()
	c.Assert(err, jc.ErrorIsNil)
	if len(data) == 0 {
		c.Fatal("got empty data from render")
	}
	d := string(data)
	if d != expectedConf {
		diff(c, d, expectedConf)
		c.Fail()
	}
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:12,代码来源:config_test.go

示例14: TestUserEvent

func (i *IntegrationSuite) TestUserEvent(c *check.C) {
	ch := make(chan Message)
	check := func(m Message) {
		ch <- m
	}
	a.RegisterHandler("UserEvent", &check)
	a.UserEvent("TestEvent", map[string]string{"Key1": "Val1", "Key2": "Val2"}, nil)

	r := <-ch
	if r["UserEvent"] != "TestEvent" || r["Key1"] != "Val1" || r["Key2"] != "Val2" {
		c.Fail()
	}
}
开发者ID:vyachin,项目名称:gami,代码行数:13,代码来源:gami_test.go

示例15: TestCb

func (s *UnitSuite) TestCb(t *check.C) {
	cb := cbList{
		&sync.RWMutex{},
		make(map[string]*func(Message)),
		make(map[string]bool),
	}

	tf := func(m Message) {}
	k := "test1"
	cb.set(k, &tf, true)

	if cb.f[k] == nil || cb.sd[k] != true {
		t.Fail()
	}

	f, sd := cb.get(k)
	if f != &tf || !sd {
		t.Fail()
	}

	cb.del(k)
	if _, e := cb.f[k]; e {
		t.Fail()
	}

	if _, e := cb.sd[k]; e {
		t.Fail()
	}
}
开发者ID:vyachin,项目名称:gami,代码行数:29,代码来源:gami_test.go


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