本文整理汇总了Golang中gopkg/in/check/v1.C.Fatalf方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Fatalf方法的具体用法?Golang C.Fatalf怎么用?Golang C.Fatalf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Fatalf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *IsolatedWorkerSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.stub = &testing.Stub{}
s.dataDir = c.MkDir()
s.hookRan = make(chan struct{})
s.triggersCreated = make(chan struct{})
triggerFactory := func(state meterstatus.WorkerState, status string, disconectedAt time.Time, clk clock.Clock, amber time.Duration, red time.Duration) (<-chan time.Time, <-chan time.Time) {
select {
case s.triggersCreated <- struct{}{}:
case <-time.After(coretesting.LongWait):
c.Fatalf("failed to signal trigger creation")
}
return meterstatus.GetTriggers(state, status, disconectedAt, clk, amber, red)
}
s.clk = testing.NewClock(time.Now())
wrk, err := meterstatus.NewIsolatedStatusWorker(
meterstatus.IsolatedConfig{
Runner: &stubRunner{stub: s.stub, ran: s.hookRan},
StateFile: meterstatus.NewStateFile(path.Join(s.dataDir, "meter-status.yaml")),
Clock: s.clk,
AmberGracePeriod: AmberGracePeriod,
RedGracePeriod: RedGracePeriod,
TriggerFactory: triggerFactory,
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(wrk, gc.NotNil)
s.worker = wrk
}
示例2: TestHTTPClient
func (s *httpSuite) TestHTTPClient(c *gc.C) {
var handler http.HandlerFunc
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
handler(w, req)
}))
defer srv.Close()
s.client.BaseURL = srv.URL
for i, test := range httpClientTests {
c.Logf("test %d: %s", i, test.about)
handler = test.handler
var resp interface{}
if test.expectResponse != nil {
resp = reflect.New(reflect.TypeOf(test.expectResponse).Elem()).Interface()
}
err := s.client.Get("/", resp)
if test.expectError != "" {
c.Check(err, gc.ErrorMatches, test.expectError)
c.Check(params.ErrCode(err), gc.Equals, test.expectErrorCode)
if err, ok := errors.Cause(err).(*params.Error); ok {
c.Check(err.Info, jc.DeepEquals, test.expectErrorInfo)
} else if test.expectErrorInfo != nil {
c.Fatalf("no error info found in error")
}
continue
}
c.Check(err, gc.IsNil)
c.Check(resp, jc.DeepEquals, test.expectResponse)
}
}
示例3: TestServiceDeath
func (s *FilterSuite) TestServiceDeath(c *gc.C) {
f, err := filter.NewFilter(s.uniter, s.unit.Tag().(names.UnitTag))
c.Assert(err, jc.ErrorIsNil)
defer statetesting.AssertStop(c, f)
dyingC := s.notifyAsserterC(c, f.UnitDying())
dyingC.AssertNoReceive()
err = s.unit.SetAgentStatus(state.StatusIdle, "", nil)
c.Assert(err, jc.ErrorIsNil)
err = s.wordpress.Destroy()
c.Assert(err, jc.ErrorIsNil)
timeout := time.After(coretesting.LongWait)
loop:
for {
select {
case <-f.UnitDying():
break loop
case <-time.After(coretesting.ShortWait):
s.BackingState.StartSync()
case <-timeout:
c.Fatalf("dead not detected")
}
}
err = s.unit.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Assert(s.unit.Life(), gc.Equals, state.Dying)
// Can't set s.wordpress to Dead while it still has units.
}
示例4: step
func (waitAddresses) step(c *gc.C, ctx *context) {
timeout := time.After(worstCase)
for {
select {
case <-timeout:
c.Fatalf("timed out waiting for unit addresses")
case <-time.After(coretesting.ShortWait):
err := ctx.unit.Refresh()
if err != nil {
c.Fatalf("unit refresh failed: %v", err)
}
// GZ 2013-07-10: Hardcoded values from dummy environ
// special cased here, questionable.
private, _ := ctx.unit.PrivateAddress()
if private.Value != "private.address.example.com" {
continue
}
public, _ := ctx.unit.PublicAddress()
if public.Value != "public.address.example.com" {
continue
}
return
}
}
}
示例5: TestExecHelperError
func (s *ExecHelperSuite) TestExecHelperError(c *gc.C) {
argChan := make(chan []string, 1)
cfg := testing.PatchExecConfig{
Stdout: "Hellooooo stdout!",
Stderr: "Hellooooo stderr!",
ExitCode: 55,
Args: argChan,
}
f := s.GetExecCommand(cfg)
stderr := &bytes.Buffer{}
stdout := &bytes.Buffer{}
cmd := f("echo", "hello world!")
cmd.Stderr = stderr
cmd.Stdout = stdout
err := cmd.Run()
c.Assert(err, gc.NotNil)
_, ok := err.(*exec.ExitError)
if !ok {
c.Errorf("Expected *exec.ExitError, but got %T", err)
} else {
c.Check(err.Error(), gc.Equals, "exit status 55")
}
c.Check(stderr.String(), gc.Equals, cfg.Stderr+"\n")
c.Check(stdout.String(), gc.Equals, cfg.Stdout+"\n")
select {
case args := <-argChan:
c.Assert(args, gc.DeepEquals, []string{"echo", "hello world!"})
default:
c.Fatalf("No arguments passed to output channel")
}
}
示例6: expectStarted
func (s *lxcProvisionerSuite) expectStarted(c *gc.C, machine *state.Machine) string {
// This check in particular leads to tests just hanging
// indefinitely quite often on i386.
coretesting.SkipIfI386(c, "lp:1425569")
var event mock.Event
s.State.StartSync()
select {
case event = <-s.events:
c.Assert(event.Action, gc.Equals, mock.Created)
argsSet := set.NewStrings(event.TemplateArgs...)
c.Assert(argsSet.Contains("imageURL"), jc.IsTrue)
case <-time.After(coretesting.LongWait):
c.Fatalf("timeout while waiting the mock container to get created")
}
select {
case event = <-s.events:
c.Assert(event.Action, gc.Equals, mock.Started)
err := machine.Refresh()
c.Assert(err, jc.ErrorIsNil)
case <-time.After(coretesting.LongWait):
c.Fatalf("timeout while waiting the mock container to start")
}
s.waitInstanceId(c, machine, instance.Id(event.InstanceId))
return event.InstanceId
}
示例7: TestCursorReuseResult
func (s *RethinkSuite) TestCursorReuseResult(c *test.C) {
// Test query
query := Expr([]interface{}{
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
},
map[string]interface{}{
"B": 1,
},
map[string]interface{}{
"A": "a",
"B": 1,
},
})
res, err := query.Run(sess)
c.Assert(err, test.IsNil)
var i int
var result SimpleT
for res.Next(&result) {
switch i {
case 0:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 1:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 2:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 0,
})
case 3:
c.Assert(result, test.DeepEquals, SimpleT{
A: "",
B: 1,
})
case 4:
c.Assert(result, test.DeepEquals, SimpleT{
A: "a",
B: 1,
})
default:
c.Fatalf("Unexpected number of results")
}
i++
}
c.Assert(res.Err(), test.IsNil)
}
示例8: assertNoMoreCalls
func assertNoMoreCalls(c *gc.C, client *mockClient) {
select {
case call := <-client.calls:
c.Fatalf("unexpected API call: %q", call)
case <-time.After(testing.ShortWait):
}
}
示例9: AssertStart
func (ews *manifoldHarness) AssertStart(c *gc.C) {
select {
case <-ews.starts:
case <-time.After(coretesting.LongWait):
c.Fatalf("never started")
}
}
示例10: TestStopInstances
func (t *LiveTests) TestStopInstances(c *gc.C) {
t.PrepareOnce(c)
// It would be nice if this test was in jujutest, but
// there's no way for jujutest to fabricate a valid-looking
// instance id.
inst0, _ := testing.AssertStartInstance(c, t.Env, "40")
inst1 := ec2.FabricateInstance(inst0, "i-aaaaaaaa")
inst2, _ := testing.AssertStartInstance(c, t.Env, "41")
err := t.Env.StopInstances(inst0.Id(), inst1.Id(), inst2.Id())
c.Check(err, jc.ErrorIsNil)
var insts []instance.Instance
// We need the retry logic here because we are waiting
// for Instances to return an error, and it will not retry
// if it succeeds.
gone := false
for a := ec2.ShortAttempt.Start(); a.Next(); {
insts, err = t.Env.Instances([]instance.Id{inst0.Id(), inst2.Id()})
if err == environs.ErrPartialInstances {
// instances not gone yet.
continue
}
if err == environs.ErrNoInstances {
gone = true
break
}
c.Fatalf("error getting instances: %v", err)
}
if !gone {
c.Errorf("after termination, instances remaining: %v", insts)
}
}
示例11: 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
}
示例12: assertNoEvent
func assertNoEvent(c *gc.C, ch <-chan interface{}, event string) {
select {
case <-ch:
c.Fatalf("unexpected " + event)
case <-time.After(coretesting.ShortWait):
}
}
示例13: TestMongoErrorNoCommonSpace
func (s *workerSuite) TestMongoErrorNoCommonSpace(c *gc.C) {
c.Skip("dimitern: test disabled as it needs refactoring")
DoTestForIPv4AndIPv6(func(ipVersion TestIPVersion) {
st, machines, hostPorts := mongoSpaceTestCommonSetup(c, ipVersion, false)
for i, machine := range machines {
// machine 10 gets a host port in space one
// machine 11 gets a host port in space two
// machine 12 gets a host port in space three
st.machine(machine).setMongoHostPorts(hostPorts[i : i+1])
}
w := startWorkerSupportingSpaces(c, st, ipVersion)
done := make(chan error)
go func() {
done <- w.Wait()
}()
select {
case err := <-done:
c.Assert(err, gc.ErrorMatches, ".*couldn't find a space containing all peer group machines")
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out waiting for worker to exit")
}
// Each machine is in a unique space, so the Mongo space should be empty
c.Assert(st.getMongoSpaceName(), gc.Equals, "")
c.Assert(st.getMongoSpaceState(), gc.Equals, state.MongoSpaceInvalid)
})
}
示例14: waitForFile
func (s *ProxyUpdaterSuite) waitForFile(c *gc.C, filename, expected string) {
//TODO(bogdanteleaga): Find a way to test this on windows
if runtime.GOOS == "windows" {
c.Skip("Proxy settings are written to the registry on windows")
}
maxWait := time.After(coretesting.LongWait)
for {
select {
case <-maxWait:
c.Fatalf("timeout while waiting for proxy settings to change")
return
case <-time.After(10 * time.Millisecond):
fileContent, err := ioutil.ReadFile(filename)
if os.IsNotExist(err) {
continue
}
c.Assert(err, jc.ErrorIsNil)
if string(fileContent) != expected {
c.Logf("file content not matching, still waiting")
continue
}
return
}
}
}
示例15: TestAcquireWaitBlocksUntilRelease
func (*limiterSuite) TestAcquireWaitBlocksUntilRelease(c *gc.C) {
l := utils.NewLimiter(2)
calls := make([]string, 0, 10)
start := make(chan bool, 0)
waiting := make(chan bool, 0)
done := make(chan bool, 0)
go func() {
<-start
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
waiting <- true
l.AcquireWait()
calls = append(calls, "waited")
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
done <- true
}()
// Start the routine, and wait for it to get to the first checkpoint
start <- true
select {
case <-waiting:
case <-time.After(longWait):
c.Fatalf("timed out waiting for 'waiting' to trigger")
}
c.Check(l.Acquire(), jc.IsFalse)
l.Release()
select {
case <-done:
case <-time.After(longWait):
c.Fatalf("timed out waiting for 'done' to trigger")
}
c.Check(calls, gc.DeepEquals, []string{"true", "true", "false", "waited", "false"})
}