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


Golang C.Failed方法代码示例

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


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

示例1: calculatePingTimeout

func (s *pingerSuite) calculatePingTimeout(c *gc.C) time.Duration {
	// Try opening an API connection a few times and take the max
	// delay among the attempts.
	attempt := utils.AttemptStrategy{
		Delay: coretesting.ShortWait,
		Min:   3,
	}
	var maxTimeout time.Duration
	for a := attempt.Start(); a.Next(); {
		openStart := time.Now()
		st, _ := s.OpenAPIAsNewMachine(c)
		err := st.Ping()
		if c.Check(err, jc.ErrorIsNil) {
			openDelay := time.Since(openStart)
			c.Logf("API open and initial ping took %v", openDelay)
			if maxTimeout < openDelay {
				maxTimeout = openDelay
			}
		}
		if st != nil {
			c.Check(st.Close(), jc.ErrorIsNil)
		}
	}
	if !c.Failed() && maxTimeout > 0 {
		return maxTimeout
	}
	c.Fatalf("cannot calculate ping timeout")
	return 0
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:29,代码来源:pinger_test.go

示例2: doConcurrentTest

func doConcurrentTest(c *test.C, ct func()) {
	maxProcs, numReqs := 1, 150
	if testing.Short() {
		maxProcs, numReqs = 4, 50
	}
	defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs))

	var wg sync.WaitGroup
	wg.Add(numReqs)

	reqs := make(chan bool)
	defer close(reqs)

	for i := 0; i < maxProcs*2; i++ {
		go func() {
			for _ = range reqs {
				ct()
				if c.Failed() {
					wg.Done()
					continue
				}
				wg.Done()
			}
		}()
	}

	for i := 0; i < numReqs; i++ {
		reqs <- true
	}

	wg.Wait()
}
开发者ID:lamielle,项目名称:gorethink,代码行数:32,代码来源:gorethink_test.go

示例3: CheckFailed

func (s *Suite) CheckFailed(c *gc.C) {
	if c.Failed() {
		c.Succeed()
	} else {
		c.Errorf("expected failure; none observed")
	}
	c.Logf("-------------------------------")
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:workertest_test.go

示例4: verifyTransitions

func verifyTransitions(model Stream, outcomes transitionCases, c *gc.C) {
	var pump chan int
	var underTest *Stream

	from := func() *Stream {
		pump = make(chan int, 1)
		underTest = &Stream{
			ID:                model.ID,
			State:             model.State,
			SendFlowAvailable: 4096,
			SendFlowPump:      pump,
		}
		return underTest
	}

	verify := func(outcome interface{}, err *Error) {
		if expected, ok := outcome.(*errCase); ok {
			c.Check(err, gc.NotNil)
			c.Check(err.Level, gc.Equals, expected.level)
			c.Check(err.Code, gc.Equals, expected.code)
			return
		}
		expected := outcome.(*successCase)
		c.Check(underTest.State, gc.Equals, expected.state)

		select {
		case r, ok := <-pump:
			if expected.pumpOpened {
				c.Check(ok, gc.Equals, true)
				c.Check(r, gc.Equals, underTest.SendFlowAvailable)
			} else if expected.pumpClosed {
				c.Check(ok, gc.Equals, false)
			} else {
				c.Error("unexpected pump update: ", r, ok)
			}
		default:
			c.Check(expected.pumpOpened, gc.Equals, false)
			c.Check(expected.pumpClosed, gc.Equals, false)
		}
		if c.Failed() {
			panic(false) // Generate a callstack.
		}
	}

	verify(outcomes.onRecvData, from().onData(Receive, false))
	verify(outcomes.onRecvDataWithFin, from().onData(Receive, true))
	verify(outcomes.onRecvHeaders, from().onHeaders(Receive, false))
	verify(outcomes.onRecvHeadersWithFin, from().onHeaders(Receive, true))
	verify(outcomes.onRecvPushPromise, from().onPushPromise(Receive))
	verify(outcomes.onRecvReset, from().onReset(Receive))
	verify(outcomes.onSendData, from().onData(Send, false))
	verify(outcomes.onSendDataWithFin, from().onData(Send, true))
	verify(outcomes.onSendHeaders, from().onHeaders(Send, false))
	verify(outcomes.onSendHeadersWithFin, from().onHeaders(Send, true))
	verify(outcomes.onSendPushPromise, from().onPushPromise(Send))
	verify(outcomes.onSendReset, from().onReset(Send))
}
开发者ID:jgraettinger,项目名称:gohttp2,代码行数:57,代码来源:stream_test.go

示例5: checkTarContents

func (s *LegacySuite) checkTarContents(
	c *gc.C, tarFile io.Reader, allExpected []tarContent,
) {
	contents := readTarFile(c, tarFile)

	// Check that the expected entries are there.
	// XXX Check for unexpected entries.
	for _, expected := range allExpected {
		relPath := strings.TrimPrefix(expected.Name, string(os.PathSeparator))

		c.Log(fmt.Sprintf("checking for presence of %q on tar file", relPath))
		body, found := contents[relPath]
		if !found {
			c.Errorf("%q not found", expected.Name)
			continue
		}

		if expected.Body != "" {
			c.Log("Also checking the file contents")
			c.Check(body, gc.Equals, expected.Body)
		}

		if expected.Nested != nil {
			c.Log("Also checking the nested tar file")
			nestedFile := bytes.NewBufferString(body)
			s.checkTarContents(c, nestedFile, expected.Nested)
		}
	}

	if c.Failed() {
		c.Log("-----------------------")
		c.Log("expected:")
		for _, expected := range allExpected {
			c.Log(fmt.Sprintf("%s -> %q", expected.Name, expected.Body))
		}
		c.Log("got:")
		for name, body := range contents {
			if len(body) > 200 {
				body = body[:200] + "...(truncated)"
			}
			c.Log(fmt.Sprintf("%s -> %q", name, body))
		}
	}
}
开发者ID:howbazaar,项目名称:juju,代码行数:44,代码来源:legacy_test.go

示例6: TestWatchCollection

func (s *FastPeriodSuite) TestWatchCollection(c *gc.C) {
	chA1 := make(chan watcher.Change)
	chB1 := make(chan watcher.Change)
	chA := make(chan watcher.Change)
	chB := make(chan watcher.Change)

	s.w.Watch("testA", 1, -1, chA1)
	s.w.Watch("testB", 1, -1, chB1)
	s.w.WatchCollection("testA", chA)
	s.w.WatchCollection("testB", chB)

	revno1 := s.insert(c, "testA", 1)
	revno2 := s.insert(c, "testA", 2)
	revno3 := s.insert(c, "testB", 1)
	revno4 := s.insert(c, "testB", 2)

	s.w.StartSync()

	seen := map[chan<- watcher.Change][]watcher.Change{}
	timeout := time.After(testing.LongWait)
	n := 0
Loop1:
	for n < 6 {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop1
		}
		n++
	}

	c.Check(seen[chA1], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB1], gc.DeepEquals, []watcher.Change{{"testB", 1, revno3}})
	c.Check(seen[chA], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}, {"testA", 2, revno2}})
	c.Check(seen[chB], gc.DeepEquals, []watcher.Change{{"testB", 1, revno3}, {"testB", 2, revno4}})
	if c.Failed() {
		return
	}

	s.w.UnwatchCollection("testB", chB)
	s.w.Unwatch("testB", 1, chB1)

	revno1 = s.update(c, "testA", 1)

	s.w.StartSync()

	timeout = time.After(testing.LongWait)
	seen = map[chan<- watcher.Change][]watcher.Change{}
	n = 0
Loop2:
	for n < 2 {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop2
		}
		n++
	}
	c.Check(seen[chA1], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB1], gc.IsNil)
	c.Check(seen[chA], gc.DeepEquals, []watcher.Change{{"testA", 1, revno1}})
	c.Check(seen[chB], gc.IsNil)

	// Check that no extra events arrive.
	seen = map[chan<- watcher.Change][]watcher.Change{}
	timeout = time.After(testing.ShortWait)
Loop3:
	for {
		select {
		case chg := <-chA1:
			seen[chA1] = append(seen[chA1], chg)
		case chg := <-chB1:
			seen[chB1] = append(seen[chB1], chg)
		case chg := <-chA:
			seen[chA] = append(seen[chA], chg)
		case chg := <-chB:
			seen[chB] = append(seen[chB], chg)
		case <-timeout:
			break Loop3
		}
	}
	c.Check(seen[chA1], gc.IsNil)
	c.Check(seen[chB1], gc.IsNil)
	c.Check(seen[chA], gc.IsNil)
	c.Check(seen[chB], gc.IsNil)
}
开发者ID:bac,项目名称:juju,代码行数:100,代码来源:watcher_test.go

示例7: TearDownSuite

func (suite *DirectoryReleaseSuite) TearDownSuite(c *check.C) {
	if !c.Failed() {
		os.RemoveAll(suite.dynPath)
	}
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:5,代码来源:DirectoryRelease_test.go

示例8: TearDownSuite

func (suite *FileResourceSuite) TearDownSuite(c *check.C) {
	if !c.Failed() {
		os.RemoveAll(suite.dynPath)
	}
}
开发者ID:inkyblackness,项目名称:shocked-core,代码行数:5,代码来源:FileResource_test.go


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