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


Golang C.Error方法代码示例

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


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

示例1: assertUpgradeNotComplete

func assertUpgradeNotComplete(c *gc.C, context *upgradeWorkerContext) {
	select {
	case <-context.UpgradeComplete:
		c.Error("UpgradeComplete channel is closed but shouldn't be")
	default:
	}
}
开发者ID:jimmiebtlr,项目名称:juju,代码行数:7,代码来源:upgrade_test.go

示例2: assertUpgradeComplete

func assertUpgradeComplete(c *gc.C, context *upgradeWorkerContext) {
	select {
	case <-context.UpgradeComplete:
	default:
		c.Error("UpgradeComplete channel is open but shouldn't be")
	}
}
开发者ID:jimmiebtlr,项目名称:juju,代码行数:7,代码来源:upgrade_test.go

示例3: TestBootstrapKeepBroken

func (s *BootstrapSuite) TestBootstrapKeepBroken(c *gc.C) {
	resetJujuHome(c)
	devVersion := version.Current
	// Force a dev version by having a non zero build number.
	// This is because we have not uploaded any tools and auto
	// upload is only enabled for dev versions.
	devVersion.Build = 1234
	s.PatchValue(&version.Current, devVersion)
	opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)), "-e", "brokenenv", "--keep-broken")
	err := <-errc
	c.Assert(err, gc.ErrorMatches, "failed to bootstrap environment: dummy.Bootstrap is broken")
	done := false
	for !done {
		select {
		case op, ok := <-opc:
			if !ok {
				done = true
				break
			}
			switch op.(type) {
			case dummy.OpDestroy:
				c.Error("unexpected call to env.Destroy")
				break
			}
		default:
			break
		}
	}
}
开发者ID:zhouqt,项目名称:juju,代码行数:29,代码来源:bootstrap_test.go

示例4: TestFakeQPubSubUnSub

func (s *S) TestFakeQPubSubUnSub(c *gocheck.C) {
	q := FakePubSubQ{}
	msgChan, err := q.Sub()
	c.Assert(err, gocheck.IsNil)
	err = q.Pub([]byte("arrakis"))
	c.Assert(err, gocheck.IsNil)
	done := make(chan bool)
	go func() {
		time.Sleep(5e8)
		q.UnSub()
	}()
	go func() {
		msgs := make([][]byte, 0)
		for msg := range msgChan {
			msgs = append(msgs, msg)
		}
		c.Assert(msgs, gocheck.DeepEquals, [][]byte{[]byte("arrakis")})
		done <- true
	}()
	select {
	case <-done:
	case <-time.After(1e9):
		c.Error("Timeout waiting for message.")
	}
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:25,代码来源:queue_test.go

示例5: TestRedisPubSubUnsub

func (s *RedismqSuite) TestRedisPubSubUnsub(c *gocheck.C) {
	var factory redismqQFactory
	q, err := factory.Get("mypubsub")
	c.Assert(err, gocheck.IsNil)
	pubSubQ, ok := q.(PubSubQ)
	c.Assert(ok, gocheck.Equals, true)
	msgChan, err := pubSubQ.Sub()
	c.Assert(err, gocheck.IsNil)
	err = pubSubQ.Pub([]byte("anla'shok"))
	c.Assert(err, gocheck.IsNil)
	done := make(chan bool)
	go func() {
		time.Sleep(5e8)
		pubSubQ.UnSub()
	}()
	go func() {
		msgs := make([][]byte, 0)
		for msg := range msgChan {
			msgs = append(msgs, msg)
		}
		c.Assert(msgs, gocheck.DeepEquals, [][]byte{[]byte("anla'shok")})
		done <- true
	}()
	select {
	case <-done:
	case <-time.After(1e9):
		c.Error("Timeout waiting for message.")
	}
}
开发者ID:rualatngua,项目名称:tsuru,代码行数:29,代码来源:redismq_test.go

示例6: TestBootstrapDestroy

func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
	resetJujuHome(c)
	devVersion := version.Current
	// Force a dev version by having a non zero build number.
	// This is because we have not uploaded any tools and auto
	// upload is only enabled for dev versions.
	devVersion.Build = 1234
	s.PatchValue(&version.Current, devVersion)
	opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), envcmd.Wrap(new(BootstrapCommand)), "-e", "brokenenv")
	err := <-errc
	c.Assert(err, gc.ErrorMatches, "failed to bootstrap environment: dummy.Bootstrap is broken")
	var opDestroy *dummy.OpDestroy
	for opDestroy == nil {
		select {
		case op := <-opc:
			switch op := op.(type) {
			case dummy.OpDestroy:
				opDestroy = &op
			}
		default:
			c.Error("expected call to env.Destroy")
			return
		}
	}
	c.Assert(opDestroy.Error, gc.ErrorMatches, "dummy.Destroy is broken")
}
开发者ID:zhouqt,项目名称:juju,代码行数:26,代码来源:bootstrap_test.go

示例7: TestWaitTicker

func (s *WaitTickerTestSuite) TestWaitTicker(t *gocheck.C) {
	wt := ticker.NewWaitTicker(2)

	tickChan := make(chan time.Time)
	wt.Add(tickChan)
	go wt.Run(0)

	ticks := []time.Time{time.Now()}
	for i := 0; i < 2; i++ {
		now := <-tickChan
		ticks = append(ticks, now)
	}
	wt.Stop()

	t.Assert(len(ticks), gocheck.Equals, 3)

	d := ticks[1].Sub(ticks[0])
	if d.Seconds() >= 1.0 {
		t.Error("Ticks when receiver ready; got %f", d.Seconds())
	}

	d = ticks[2].Sub(ticks[1])
	if d.Seconds() < 1.9 || d.Seconds() > 2.5 {
		t.Error("Waits interval seconds; got %f", d.Seconds())
	}
}
开发者ID:huangzhiyong,项目名称:percona-agent,代码行数:26,代码来源:ticker_test.go

示例8: assertContainerRestarts

func (s *IntegrationTestSuite) assertContainerRestarts(c *chk.C, id containers.Identifier) {
	isStarted := func() bool {
		active, sub := s.unitState(id)
		if active == "active" {
			return true
		}
		if active == "deactivating" || active == "activating" {
			return false
		}
		c.Errorf("Unit %s restart failed (%s) in unexpected state %s", id, active, sub)
		c.FailNow()
		return false
	}

	if !until(CONTAINER_STATE_CHANGE_TIMEOUT, CONTAINER_CHECK_INTERVAL, isStarted) {
		active, sub := s.unitState(id)
		c.Errorf("Timeout during restart of %s, never got back to 'active' state (%s/%s)", id, active, sub)
		c.FailNow()
	}

	container, err := s.dockerClient.GetContainer(id.ContainerFor(), false)
	if err != nil {
		c.Error("Can't check container "+id, err)
		c.FailNow()
	}
	if !container.State.Running {
		c.Logf("Container %s exists, but is not running - race condition %+v", id, container.State)
	}
}
开发者ID:smarterclayton,项目名称:geard,代码行数:29,代码来源:integration_test.go

示例9: TestMpris

func (t *testWrap) TestMpris(c *C.C) {
	os.Setenv("XDG_DATA_DIRS", "testdata/share")
	if _, ok := getCommandByMimeType("text/plain"); ok == false {
		c.Error("getCommandByMimeType failed")
		return
	}
}
开发者ID:felixonmars,项目名称:dde-daemon,代码行数:7,代码来源:mpris_test.go

示例10: TestBootstrapDestroy

func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
	_, fake := makeEmptyFakeHome(c)
	defer fake.Restore()
	devVersion := version.Current
	// Force a dev version by having an odd minor version number.
	// This is because we have not uploaded any tools and auto
	// upload is only enabled for dev versions.
	devVersion.Minor = 11
	s.PatchValue(&version.Current, devVersion)
	opc, errc := runCommand(nullContext(c), new(BootstrapCommand), "-e", "brokenenv")
	err := <-errc
	c.Assert(err, gc.ErrorMatches, "dummy.Bootstrap is broken")
	var opDestroy *dummy.OpDestroy
	for opDestroy == nil {
		select {
		case op := <-opc:
			switch op := op.(type) {
			case dummy.OpDestroy:
				opDestroy = &op
			}
		default:
			c.Error("expected call to env.Destroy")
			return
		}
	}
	c.Assert(opDestroy.Error, gc.ErrorMatches, "dummy.Destroy is broken")
}
开发者ID:jameinel,项目名称:core,代码行数:27,代码来源:bootstrap_test.go

示例11: TestSkip

func (s *FoundationS) TestSkip(c *gocheck.C) {
	helper := SkipTestHelper{}
	output := String{}
	gocheck.Run(&helper, &gocheck.RunConf{Output: &output})

	if output.value != "" {
		c.Error("Skip() logged something:\n", output.value)
	}
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:9,代码来源:foundation_test.go

示例12: TestError

func (s *FoundationS) TestError(c *gocheck.C) {
	expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
		"    c\\.Error\\(\"Error \", \"message!\"\\)\n"+
		"\\.\\.\\. Error: Error message!\n\n",
		getMyLine()+1)
	c.Error("Error ", "message!")
	checkState(c, nil,
		&expectedState{
			name:   "Error(`Error `, `message!`)",
			failed: true,
			log:    expectedLog,
		})
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:13,代码来源:foundation_test.go

示例13: assertContainerStarts

func (s *IntegrationTestSuite) assertContainerStarts(c *chk.C, id containers.Identifier) {
	active, _ := s.unitState(id)
	switch active {
	case "active":
		return
	case "activating":
		break
	default:
		c.Errorf("Container %s failed to start - %s", id, active)
		c.FailNow()
		return
	}

	isRunning := func() bool {
		active, sub := s.unitState(id)
		if active == "active" {
			return true
		}
		if active == "activating" {
			return false
		}
		c.Errorf("Unit %s start failed with state %s", id, sub)
		c.FailNow()
		return false
	}

	if !until(TimeoutContainerStateChange, time.Second/20, isRunning) {
		c.Errorf("Timeout during start of %s, never got to 'active' state", id)
		c.FailNow()
	}

	// Docker does not immediately return container status - possibly due to races inside of the
	// daemon
	failed := false
	isContainerUp := func() bool {
		done, err := isContainerAvailable(s.dockerClient, id.ContainerFor())
		if err != nil {
			failed = true
			c.Error("Docker couldn't return container info", err)
			c.FailNow()
		}
		return done
	}

	if !until(TimeoutDockerWait, IntervalHttpCheck, isContainerUp) {
		if !failed {
			c.Errorf("Docker never reported the container running %s", id)
		}
		c.FailNow()
	}
}
开发者ID:jhadvig,项目名称:geard,代码行数:51,代码来源:integration_test.go

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

示例15: TestMinLogger

func (s *BootstrapS) TestMinLogger(c *gocheck.C) {
	var logger minLogger
	logger = log.New(os.Stderr, "", 0)
	logger = c
	logger.Output(0, "Hello there")
	expected := "\\[LOG\\] [.0-9]+ Hello there\n"
	output := c.GetTestLog()
	matched, err := regexp.MatchString(expected, output)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("Output() didn't log properly:\n", output)
	}
}
开发者ID:evaluation-alex,项目名称:gosync,代码行数:14,代码来源:foundation_test.go


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