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


Golang C.Error方法代码示例

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


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

示例1: waitBeforeClose

func (s *stubSender) waitBeforeClose(c *gc.C) {
	select {
	case <-s.waitCloseCh:
	case <-time.After(coretesting.LongWait):
		c.Error("timed out waiting")
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:logforwarder_test.go

示例2: TestTimoutClosesAPIOnTimeout

func (*APIOpenerSuite) TestTimoutClosesAPIOnTimeout(c *gc.C) {
	var name string
	finished := make(chan struct{})
	mockConn := &mockConnection{closed: make(chan struct{})}
	open := func(connectionName string) (api.Connection, error) {
		<-finished
		name = connectionName
		return mockConn, nil
	}
	// have the mock clock only wait a microsecond
	clock := &mockClock{wait: time.Microsecond}
	// but tell it to wait five seconds
	opener := envcmd.NewTimeoutOpener(open, clock, 5*time.Second)
	conn, err := opener.Open("a-name")
	c.Assert(errors.Cause(err), gc.Equals, envcmd.ErrConnTimedOut)
	c.Assert(conn, gc.IsNil)
	// check it was told to wait for 5 seconds
	c.Assert(clock.duration, gc.Equals, 5*time.Second)
	// tell the open func to continue now we have timed out
	close(finished)
	// wait until the connection has been closed
	select {
	case <-mockConn.closed:
		// continue
	case <-time.After(5 * time.Second):
		c.Error("API connection was not closed.")
	}
	c.Assert(name, gc.Equals, "a-name")
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:apiopener_test.go

示例3: waitAfterSend

func (s *stubSender) waitAfterSend(c *gc.C) {
	select {
	case <-s.waitSendCh:
	case <-time.After(coretesting.LongWait):
		c.Error("timed out waiting")
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:logforwarder_test.go

示例4: TestBootstrapKeepBroken

func (s *BootstrapSuite) TestBootstrapKeepBroken(c *gc.C) {
	resetJujuHome(c, "devenv")
	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:kakamessi99,项目名称:juju,代码行数:29,代码来源:bootstrap_test.go

示例5: assertUpgradeNotComplete

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

示例6: assertUpgradeComplete

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

示例7: TestTimoutClosesAPIOnTimeout

func (*APIOpenerSuite) TestTimoutClosesAPIOnTimeout(c *gc.C) {
	var controllerName, accountName, modelName string
	finished := make(chan struct{})
	mockConn := &mockConnection{closed: make(chan struct{})}
	open := func(_ jujuclient.ClientStore, controllerNameArg, accountNameArg, modelNameArg string) (api.Connection, error) {
		<-finished
		controllerName = controllerNameArg
		accountName = accountNameArg
		modelName = modelNameArg
		return mockConn, nil
	}
	// have the mock clock only wait a microsecond
	clock := &mockClock{wait: time.Microsecond}
	// but tell it to wait five seconds
	opener := modelcmd.NewTimeoutOpener(modelcmd.OpenFunc(open), clock, 5*time.Second)
	conn, err := opener.Open(nil, "a-name", "b-name", "c-name")
	c.Assert(errors.Cause(err), gc.Equals, modelcmd.ErrConnTimedOut)
	c.Assert(conn, gc.IsNil)
	// check it was told to wait for 5 seconds
	c.Assert(clock.duration, gc.Equals, 5*time.Second)
	// tell the open func to continue now we have timed out
	close(finished)
	// wait until the connection has been closed
	select {
	case <-mockConn.closed:
		// continue
	case <-time.After(5 * time.Second):
		c.Error("API connection was not closed.")
	}
	c.Assert(controllerName, gc.Equals, "a-name")
	c.Assert(accountName, gc.Equals, "b-name")
	c.Assert(modelName, gc.Equals, "c-name")
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:33,代码来源:apiopener_test.go

示例8: waitAfterNext

func (s *stubStream) waitAfterNext(c *gc.C) {
	select {
	case <-s.waitCh:
	case <-time.After(coretesting.LongWait):
		c.Error("timed out waiting")
	}
}
开发者ID:kat-co,项目名称:juju,代码行数:7,代码来源:logforwarder_test.go

示例9: assertUpgradeNotComplete

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

示例10: TestBootstrapKeepBroken

func (s *BootstrapSuite) TestBootstrapKeepBroken(c *gc.C) {
	resetJujuHome(c, "devenv")
	s.patchVersion(c)

	opc, errc := cmdtesting.RunCommand(cmdtesting.NullContext(c), newBootstrapCommand(), "-e", "brokenenv", "--keep-broken", "--auto-upgrade")
	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:imoapps,项目名称:juju,代码行数:25,代码来源:bootstrap_test.go

示例11: NewTCPProxy

// NewTCPProxy runs a proxy that copies to and from
// the given remote TCP address. When the proxy
// is closed, its listener and all connections will be closed.
func NewTCPProxy(c *gc.C, remoteAddr string) *TCPProxy {
	listener, err := net.Listen("tcp", "127.0.0.1:0")
	c.Assert(err, jc.ErrorIsNil)
	p := &TCPProxy{
		listener: listener,
	}
	go func() {
		for {
			client, err := p.listener.Accept()
			if err != nil {
				if !p.isClosed() {
					c.Error("cannot accept: %v", err)
				}
				return
			}
			p.addConn(client)
			server, err := net.Dial("tcp", remoteAddr)
			if err != nil {
				if !p.isClosed() {
					c.Error("cannot dial remote address: %v", err)
				}
				return
			}
			p.addConn(server)
			go stream(client, server)
			go stream(server, client)
		}
	}()
	return p
}
开发者ID:juju,项目名称:testing,代码行数:33,代码来源:tcpproxy.go

示例12: assertUpgradeComplete

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

示例13: TestBootstrapDestroy

func (s *BootstrapSuite) TestBootstrapDestroy(c *gc.C) {
	resetJujuHome(c, "devenv")
	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:kakamessi99,项目名称:juju,代码行数:26,代码来源:bootstrap_test.go

示例14: TestCollectionOnClosedSessionGraceful

// TestCollectionOnClosedSessionGraceful closes the session directly and checks
// we handle this cleanly without panicing.
func (s *collectionSizeSuite) TestCollectionOnClosedSessionGraceful(c *gc.C) {
	session := s.Session.Copy()
	collection := session.DB("test").C("test_collection")
	u := monitoring.NewCollectionSizeCollector("test", "test", "test", collection)
	defer u.Close()

	err := collection.Insert(bson.M{"test": true})
	c.Assert(err, jc.ErrorIsNil)

	// We close the session directly.
	// As the collector has copied the session, this should not
	// impact its behaviour - it should continue to monitor as usual.
	session.Close()

	ch := make(chan prometheus.Metric, 2)

	u.Collect(ch)
	// read the size
	select {
	case <-ch:
	default:
		c.Error("metric not provided by collector")
	}

	// read the count
	select {
	case <-ch:
	default:
		c.Error("metric not provided by collector")
	}
}
开发者ID:cloud-green,项目名称:monitoring,代码行数:33,代码来源:collection_size_test.go

示例15: checkSameStrings

func (s *filesSuite) checkSameStrings(c *gc.C, actual, expected []string) {
	sActual := set.NewStrings(actual...)
	sExpected := set.NewStrings(expected...)

	sActualOnly := sActual.Difference(sExpected)
	sExpectedOnly := sExpected.Difference(sActual)

	if !sActualOnly.IsEmpty() || !sExpectedOnly.IsEmpty() {
		c.Error("strings mismatch")
		onlyActual := sActualOnly.Values()
		onlyExpected := sExpectedOnly.Values()
		sort.Strings(onlyActual)
		sort.Strings(onlyExpected)

		if !sActualOnly.IsEmpty() {
			c.Log("...unexpected values:")
			for _, str := range onlyActual {
				c.Log(" " + str)
			}
		}
		if !sExpectedOnly.IsEmpty() {
			c.Log("...missing values:")
			for _, str := range onlyExpected {
				c.Log(" " + str)
			}
		}
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:28,代码来源:files_test.go


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