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


Golang C.Fatal方法代码示例

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


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

示例1: TestRemoveUnits

func (s *S) TestRemoveUnits(c *gocheck.C) {
	var calls int32
	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		v := atomic.LoadInt32(&calls)
		atomic.StoreInt32(&calls, v+1)
		w.WriteHeader(http.StatusNoContent)
	}))
	srvc := service.Service{Name: "mysql", Endpoint: map[string]string{"production": ts.URL}}
	err := srvc.Create()
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Services().Remove(bson.M{"_id": "mysql"})
	app := App{
		Name:      "chemistry",
		Framework: "python",
	}
	instance := service.ServiceInstance{
		Name:        "my-inst",
		ServiceName: "mysql",
		Teams:       []string{s.team.Name},
		Apps:        []string{app.Name},
	}
	instance.Create()
	defer s.conn.ServiceInstances().Remove(bson.M{"name": "my-inst"})
	err = s.conn.Apps().Insert(app)
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Apps().Remove(bson.M{"name": app.Name})
	c.Assert(err, gocheck.IsNil)
	s.provisioner.Provision(&app)
	defer s.provisioner.Destroy(&app)
	app.AddUnits(4)
	otherApp := App{Name: app.Name, Units: app.Units}
	err = otherApp.RemoveUnits(2)
	c.Assert(err, gocheck.IsNil)
	ts.Close()
	units := s.provisioner.GetUnits(&app)
	c.Assert(units, gocheck.HasLen, 3) // when you provision you already have one, so it's 4+1-2 (in provisioner, in app struct we have 2)
	c.Assert(units[0].Name, gocheck.Equals, "chemistry/0")
	c.Assert(units[1].Name, gocheck.Equals, "chemistry/3")
	c.Assert(units[2].Name, gocheck.Equals, "chemistry/4")
	err = app.Get()
	c.Assert(err, gocheck.IsNil)
	c.Assert(app.Framework, gocheck.Equals, "python")
	c.Assert(app.Units, gocheck.HasLen, 2)
	c.Assert(app.Units[0].Name, gocheck.Equals, "chemistry/3")
	c.Assert(app.Units[1].Name, gocheck.Equals, "chemistry/4")
	ok := make(chan int8)
	go func() {
		for _ = range time.Tick(1e3) {
			if atomic.LoadInt32(&calls) == 2 {
				ok <- 1
				return
			}
		}
	}()
	select {
	case <-ok:
	case <-time.After(2e9):
		c.Fatal("Did not call service endpoint twice.")
	}
}
开发者ID:nedmax,项目名称:tsuru,代码行数:60,代码来源:app_test.go

示例2: TestPiler

func (s *S) TestPiler(c *check.C) {
	epsilon := 0.95
	for _, f := range []PileFilter{
		nil,
		func(a, b *feat.Feature, pa, pb *PileInterval) bool {
			lpa := float64(pa.End - pa.Start)
			lpb := float64(pb.End - pb.Start)

			return float64(a.Len()) >= lpa*epsilon || float64(b.Len()) >= lpb*epsilon
		},
	} {
		p := NewPiler(0)
		for _, fp := range testPairs {
			err := p.Add(fp)
			if err != nil {
				c.Fatal(err)
			}
		}

		piles, err := p.Piles(f)
		if err != nil {
			c.Fatal(err)
		}

		for i, pi := range piles {
			c.Logf("%d %v", i, pi)
			for _, fp := range pi.Images {
				c.Logf("\t%v", fp)
				c.Check(fp.A.Meta, check.DeepEquals, pi)
			}
		}
	}
}
开发者ID:frogs,项目名称:biogo,代码行数:33,代码来源:pile_test.go

示例3: TestGetItemQuery

func (s *QueryBuilderSuite) TestGetItemQuery(c *gocheck.C) {
	primary := dynamodb.NewStringAttribute("domain", "")
	key := dynamodb.PrimaryKey{primary, nil}
	table := s.server.NewTable("sites", key)

	q := dynamodb.NewQuery(table)
	q.AddKey(table, &dynamodb.Key{HashKey: "test"})

	queryJson, err := simplejson.NewJson([]byte(q.String()))
	if err != nil {
		c.Fatal(err)
	}

	expectedJson, err := simplejson.NewJson([]byte(`
{
	"Key": {
		"domain": {
			"S": "test"
		}
	},
	"TableName": "sites"
}
	`))
	if err != nil {
		c.Fatal(err)
	}
	c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
开发者ID:nabeken,项目名称:goamz,代码行数:28,代码来源:query_builder_test.go

示例4: TestWrite

func (s *S) TestWrite(c *check.C) {
	b := &B{&bytes.Buffer{}}
	w := NewWriter(b, 0, 60, false)
	for _, t := range T {
		if f1, err := featureOf(ps, t.start, t.end, false); err != nil {
			c.Fatal(err)
		} else {
			if f2, err := featureOf(ps, t.start, t.end, false); err != nil {
				c.Fatal(err)
			} else {
				n, err := w.Write(&FeaturePair{A: f1, B: f2})
				c.Check(n, check.Not(check.Equals), 0)
				c.Check(err, check.Equals, nil)
			}
		}
	}
	c.Check(string(b.Bytes()), check.Equals, "")
	w.Close()
	c.Check(string(b.Bytes()), check.Equals,
		`deBruijn2	pals	hit	1	6	0.0000	.	.	Target deBruijn2 1 6; maxe 0
deBruijn2	pals	hit	2	6	0.0000	.	.	Target deBruijn2 2 6; maxe 0
deBruijn2	pals	hit	1	16	0.0000	.	.	Target deBruijn2 1 16; maxe 0
deBruijn1	pals	hit	1	4	0.0000	.	.	Target deBruijn1 1 4; maxe 0
deBruijn5	pals	hit	1	904	0.0000	.	.	Target deBruijn5 1 904; maxe 0
deBruijn8	pals	hit	1025	4095	0.0000	.	.	Target deBruijn8 1025 4095; maxe 0
`)
}
开发者ID:frogs,项目名称:biogo,代码行数:27,代码来源:pals_test.go

示例5: TestHash

// Tests
func (s *S) TestHash(c *check.C) {
	var (
		err     error
		f       *os.File
		md5hash []byte
	)

	// FIXME: This will not work with MacOS.
	if _, err = exec.LookPath("md5sum"); err != nil {
		c.Skip(err.Error())
	}
	md5sum := exec.Command("md5sum", "./files_test.go")
	b := &bytes.Buffer{}
	md5sum.Stdout = b
	if err = md5sum.Run(); err != nil {
		c.Fatal(err)
	}
	if f, err = os.Open("./files_test.go"); err != nil {
		c.Fatalf("%v %s", md5sum, err)
	}
	if md5hash, err = Hash(md5.New(), f); err != nil {
		c.Fatal(err)
	}
	md5string := fmt.Sprintf("%x .*\n", md5hash)

	c.Check(string(b.Bytes()), check.Matches, md5string)
}
开发者ID:jaredwilkening,项目名称:biogo,代码行数:28,代码来源:files_test.go

示例6: TestKmerFrequencies

func (s *S) TestKmerFrequencies(c *check.C) {
	for k := MinKmerLen; k <= MaxKmerLen; k++ {
		if i, err := New(k, s.Seq); err != nil {
			c.Fatalf("New KmerIndex failed: %v", err)
		} else {
			freqs, ok := i.KmerFrequencies()
			c.Check(ok, check.Equals, true)
			hashFreqs := make(map[string]int)
			for i := 0; i+k <= s.Seq.Len(); i++ {
				hashFreqs[string(s.Seq.Seq[i:i+k])]++
			}
			for key := range freqs {
				if freqs[key] != hashFreqs[i.Stringify(key)] {
					c.Logf("seq %s\n", s.Seq)
					c.Logf("key %x, string of %q\n", key, i.Stringify(key))
				}
				c.Check(freqs[key], check.Equals, hashFreqs[i.Stringify(key)])
			}
			for key := range hashFreqs {
				if keyKmer, err := i.KmerOf(key); err != nil {
					c.Fatal(err)
				} else {
					if freqs[keyKmer] != hashFreqs[key] {
						c.Logf("seq %s\n", s.Seq)
						c.Logf("keyKmer %x, string of %q, key %q\n", keyKmer, i.Stringify(keyKmer), key)
					}
					c.Check(freqs[keyKmer], check.Equals, hashFreqs[key])
				}
			}
		}
	}
}
开发者ID:jaredwilkening,项目名称:biogo,代码行数:32,代码来源:kmerindex_test.go

示例7: TestWeightedTimeSeeded

func (s *S) TestWeightedTimeSeeded(c *check.C) {
	c.Log("Note: This test is stochastic and is expected to fail with probability ≈ 0.05.")
	rand.Seed(time.Now().Unix())
	f := make([]float64, len(sel))
	ts := make(Selector, len(sel))

	for i := 0; i < 1e6; i++ {
		copy(ts, sel)
		ts.Init()
		item, err := ts.Select()
		if err != nil {
			c.Fatal(err)
		}
		f[item-1]++
	}

	fsum, exsum := 0., 0.
	for i := range f {
		fsum += f[i]
		exsum += exp[i]
	}
	fac := fsum / exsum
	for i := range f {
		exp[i] *= fac
	}

	// Check that our obtained values are within statistical expectations for p = 0.05.
	// This will not be true approximately 1 in 20 tests.
	X := chi2(f, exp)
	c.Logf("H₀: d(Sample) = d(Expect), H₁: d(S) ≠ d(Expect). df = %d, p = 0.05, X² threshold = %.2f, X² = %f", len(f)-1, sigChi2, X)
	c.Check(X < sigChi2, check.Equals, true)
}
开发者ID:kortschak,项目名称:graph,代码行数:32,代码来源:weighted_test.go

示例8: TestCreateTokenRemoveOldTokens

func (s *S) TestCreateTokenRemoveOldTokens(c *gocheck.C) {
	config.Set("auth:max-simultaneous-sessions", 2)
	u := User{Email: "[email protected]", Password: "123456"}
	err := u.Create()
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Users().Remove(bson.M{"email": u.Email})
	defer s.conn.Tokens().RemoveAll(bson.M{"useremail": u.Email})
	t1, err := newUserToken(&u)
	c.Assert(err, gocheck.IsNil)
	t2 := t1
	t2.Token += "aa"
	err = s.conn.Tokens().Insert(t1, t2)
	_, err = u.CreateToken("123456")
	c.Assert(err, gocheck.IsNil)
	ok := make(chan bool, 1)
	go func() {
		for {
			ct, err := s.conn.Tokens().Find(bson.M{"useremail": u.Email}).Count()
			c.Assert(err, gocheck.IsNil)
			if ct == 2 {
				ok <- true
				return
			}
			runtime.Gosched()
		}
	}()
	select {
	case <-ok:
	case <-time.After(2e9):
		c.Fatal("Did not remove old tokens after 2 seconds")
	}
}
开发者ID:rpeterson,项目名称:tsuru,代码行数:32,代码来源:user_test.go

示例9: TestProvisionerDestroy

func (s *S) TestProvisionerDestroy(c *gocheck.C) {
	err := newImage("tsuru/python", s.server.URL())
	c.Assert(err, gocheck.IsNil)
	cont, err := s.newContainer(nil)
	c.Assert(err, gocheck.IsNil)
	app := testing.NewFakeApp(cont.AppName, "python", 1)
	var p dockerProvisioner
	p.Provision(app)
	c.Assert(p.Destroy(app), gocheck.IsNil)
	ok := make(chan bool, 1)
	go func() {
		coll := collection()
		defer coll.Close()
		for {
			ct, err := coll.Find(bson.M{"appname": cont.AppName}).Count()
			if err != nil {
				c.Fatal(err)
			}
			if ct == 0 {
				ok <- true
				return
			}
			runtime.Gosched()
		}
	}()
	select {
	case <-ok:
	case <-time.After(10e9):
		c.Fatal("Timed out waiting for the container to be destroyed (10 seconds)")
	}
	c.Assert(rtesting.FakeRouter.HasBackend("myapp"), gocheck.Equals, false)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:32,代码来源:provisioner_test.go

示例10: SetUp

func (s *AmazonServer) SetUp(c *gocheck.C) {
	auth, err := aws.EnvAuth()
	if err != nil {
		c.Fatal(err)
	}
	s.auth = auth
}
开发者ID:newhouseb,项目名称:goamz,代码行数:7,代码来源:elbi_test.go

示例11: TestUndirectedConnectedComponent

func (s *S) TestUndirectedConnectedComponent(c *check.C) {
	g := undirected(c, uv)
	f := func(_ Edge) bool { return true }
	c.Check(len(g.ConnectedComponents(f)), check.Equals, 1)
	g.DeleteByID(deleteNode)
	nodes, edges := make(map[int]int), make(map[int]int)
	for _, n := range uv {
		nodes[n.u], nodes[n.v] = 1, 1
		edges[n.u]++
		edges[n.v]++
	}
	c.Check(g.Order(), check.Equals, len(nodes)-1)
	c.Check(g.Size(), check.Equals, len(uv)-edges[deleteNode])
	cc := g.ConnectedComponents(f)
	c.Check(len(cc), check.Equals, 2)
	for i, p := range cc {
		c.Check(len(p), check.Equals, partSizes[i])
		for _, n := range p {
			c.Check(parts[n.ID()], check.Equals, i)
		}
		g0, err := p.BuildUndirected(true)
		if err != nil {
			c.Fatal(err)
		}
		c.Check(g0.Order(), check.Equals, partSizes[i])
		c.Check(g0.Size(), check.Equals, partSizes[i])
	}
}
开发者ID:kortschak,项目名称:graph,代码行数:28,代码来源:undirected_test.go

示例12: TestCollectStatusIDChangeFromPending

func (s *S) TestCollectStatusIDChangeFromPending(c *gocheck.C) {
	server, url := badGatewayServer()
	defer server.Close()
	tmpdir, err := commandmocker.Add("juju", generateOutput(url))
	c.Assert(err, gocheck.IsNil)
	defer commandmocker.Remove(tmpdir)
	p := JujuProvisioner{}
	collection := p.unitsCollection()
	defer collection.Close()
	err = collection.Insert(instance{UnitName: "as_i_rise/0", InstanceID: "pending"})
	c.Assert(err, gocheck.IsNil)
	defer collection.Remove(bson.M{"_id": bson.M{"$in": []string{"as_i_rise/0", "the_infanta/0"}}})
	_, err = p.CollectStatus()
	c.Assert(err, gocheck.IsNil)
	done := make(chan int8)
	go func() {
		for {
			q := bson.M{"_id": "as_i_rise/0", "instanceid": "i-00000439"}
			ct, err := collection.Find(q).Count()
			c.Assert(err, gocheck.IsNil)
			if ct == 1 {
				done <- 1
				return
			}
			runtime.Gosched()
		}
	}()
	select {
	case <-done:
	case <-time.After(5e9):
		c.Fatal("Did not update the unit after 5 seconds.")
	}
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:33,代码来源:collector_test.go

示例13: TestCollectStatusIDChangeDisabledELB

func (s *S) TestCollectStatusIDChangeDisabledELB(c *gocheck.C) {
	tmpdir, err := commandmocker.Add("juju", collectOutput)
	c.Assert(err, gocheck.IsNil)
	defer commandmocker.Remove(tmpdir)
	p := JujuProvisioner{}
	conn, collection := p.unitsCollection()
	defer conn.Close()
	err = collection.Insert(instance{UnitName: "as_i_rise/0", InstanceId: "i-00000239"})
	c.Assert(err, gocheck.IsNil)
	defer collection.Remove(bson.M{"_id": bson.M{"$in": []string{"as_i_rise/0", "the_infanta/0"}}})
	_, err = p.CollectStatus()
	c.Assert(err, gocheck.IsNil)
	done := make(chan int8)
	go func() {
		for {
			q := bson.M{"_id": "as_i_rise/0", "instanceid": "i-00000439"}
			ct, err := collection.Find(q).Count()
			c.Assert(err, gocheck.IsNil)
			if ct == 1 {
				done <- 1
				return
			}
			time.Sleep(1e3)
		}
	}()
	select {
	case <-done:
	case <-time.After(5e9):
		c.Fatal("Did not update the unit after 5 seconds.")
	}
}
开发者ID:kaiquewdev,项目名称:tsuru,代码行数:31,代码来源:provisioner_test.go

示例14: WaitUntilStatus

func (s *DynamoDBTest) WaitUntilStatus(c *gocheck.C, status string) {
	// We should wait until the table is in specified status because a real DynamoDB has some delay for ready
	done := make(chan bool)
	timeout := time.After(TIMEOUT)
	go func() {
		for {
			select {
			case <-done:
				return
			default:
				desc, err := s.table.DescribeTable()
				if err != nil {
					c.Fatal(err)
				}
				if desc.TableStatus == status {
					done <- true
					return
				}
				time.Sleep(5 * time.Second)
			}
		}
	}()
	select {
	case <-done:
		break
	case <-timeout:
		c.Errorf("Expect a status to be %s, but timed out", status)
		close(done)
	}
}
开发者ID:hailocab,项目名称:goamz,代码行数:30,代码来源:dynamodb_test.go

示例15: TestProvisionerProvision

func (s *S) TestProvisionerProvision(c *gocheck.C) {
	config.Set("local:authorized-key-path", "somepath")
	rfs := &fstesting.RecordingFs{}
	fsystem = rfs
	defer func() {
		fsystem = nil
	}()
	f, _ := os.Open("testdata/dnsmasq.leases")
	data, err := ioutil.ReadAll(f)
	c.Assert(err, gocheck.IsNil)
	file, err := rfs.Create("/var/lib/misc/dnsmasq.leases")
	c.Assert(err, gocheck.IsNil)
	_, err = file.Write(data)
	c.Assert(err, gocheck.IsNil)
	tmpdir, err := commandmocker.Add("sudo", "$*")
	c.Assert(err, gocheck.IsNil)
	defer commandmocker.Remove(tmpdir)
	sshTempDir, err := commandmocker.Add("ssh", "$*")
	c.Assert(err, gocheck.IsNil)
	defer commandmocker.Remove(sshTempDir)
	scpTempDir, err := commandmocker.Add("scp", "$*")
	c.Assert(err, gocheck.IsNil)
	defer commandmocker.Remove(scpTempDir)
	var p LocalProvisioner
	app := testing.NewFakeApp("myapp", "python", 0)
	defer p.collection().Remove(bson.M{"name": "myapp"})
	c.Assert(p.Provision(app), gocheck.IsNil)
	ok := make(chan bool, 1)
	go func() {
		for {
			coll := s.conn.Collection(s.collName)
			ct, err := coll.Find(bson.M{"name": "myapp", "status": provision.StatusStarted}).Count()
			if err != nil {
				c.Fatal(err)
			}
			if ct > 0 {
				ok <- true
				return
			}
			time.Sleep(1e3)
		}
	}()
	select {
	case <-ok:
	case <-time.After(10e9):
		c.Fatal("Timed out waiting for the container to be provisioned (10 seconds)")
	}
	c.Assert(commandmocker.Ran(tmpdir), gocheck.Equals, true)
	expected := "lxc-create -t ubuntu -n myapp -- -S somepath"
	expected += "lxc-start --daemon -n myapp"
	expected += "service nginx restart"
	c.Assert(commandmocker.Output(tmpdir), gocheck.Equals, expected)
	var unit provision.Unit
	err = s.conn.Collection(s.collName).Find(bson.M{"name": "myapp"}).One(&unit)
	c.Assert(err, gocheck.IsNil)
	c.Assert(unit.Ip, gocheck.Equals, "10.10.10.15")
}
开发者ID:bardusco,项目名称:tsuru,代码行数:57,代码来源:provisioner_test.go


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