本文整理汇总了Golang中launchpad/net/gocheck.C.SucceedNow方法的典型用法代码示例。如果您正苦于以下问题:Golang C.SucceedNow方法的具体用法?Golang C.SucceedNow怎么用?Golang C.SucceedNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gocheck.C
的用法示例。
在下文中一共展示了C.SucceedNow方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestListKeys
// Tests for Keys API
func (s *CloudAPISuite) TestListKeys(c *gc.C) {
k := s.createKey(c, testKeyName, testKey)
defer s.deleteKey(c, testKeyName)
keys, err := s.service.ListKeys()
c.Assert(err, gc.IsNil)
for _, key := range keys {
if c.Check(&key, gc.DeepEquals, k) {
c.SucceedNow()
}
}
c.Fatalf("Obtained keys [%s] do not contain test key [%s]", keys, k)
}
示例2: TestListMachines
// Test for Machine API
func (s *CloudAPISuite) TestListMachines(c *gc.C) {
m := s.createMachine(c, testMachineName, testPackage, testImage, nil, nil)
defer s.deleteMachine(c, m.Id)
machines, err := s.service.ListMachines(nil)
c.Assert(err, gc.IsNil)
for _, machine := range machines {
if machine.Id == m.Id {
c.SucceedNow()
}
}
c.Fatalf("Obtained machine [%v] do not contain test machine [%v]", machines, m)
}
示例3: 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")
}
示例4: TestInferURL
func (s *PublishSuite) TestInferURL(c *gc.C) {
addMeta(c, s.branch, "")
cmd := &PublishCommand{}
cmd.ChangePushLocation(func(location string) string {
c.Assert(location, gc.Equals, "lp:charms/precise/wordpress")
c.SucceedNow()
panic("unreachable")
})
_, err := testing.RunCommandInDir(c, envcmd.Wrap(cmd), []string{"precise/wordpress"}, s.dir)
c.Assert(err, gc.IsNil)
c.Fatal("shouldn't get here; location closure didn't run?")
}
示例5: TestListKeys
func (s *LiveTests) TestListKeys(c *gc.C) {
s.createKey(c)
keys, err := s.testClient.ListKeys()
c.Assert(err, gc.IsNil)
c.Assert(keys, gc.NotNil)
fakeKey := cloudapi.Key{Name: "fake-key", Fingerprint: testKeyFingerprint, Key: testKey}
for _, k := range keys {
if c.Check(k, gc.DeepEquals, fakeKey) {
c.SucceedNow()
}
}
c.Fatalf("Obtained keys [%s] do not contain test key [%s]", keys, fakeKey)
}
示例6: TestListMachines
// Tests for Machines API
func (s *CloudAPIHTTPSuite) TestListMachines(c *gc.C) {
var expected []cloudapi.Machine
m := s.createMachine(c, testMachineName, testPackage, testImage, nil, nil)
defer s.deleteMachine(c, m.Id)
resp, err := s.sendRequest("GET", path.Join(testUserAccount, "machines"), nil, nil)
c.Assert(err, gc.IsNil)
c.Assert(resp.StatusCode, gc.Equals, http.StatusOK)
assertJSON(c, resp, &expected)
for _, machine := range expected {
if machine.Id == m.Id {
c.SucceedNow()
}
}
c.Fatalf("Obtained machine [%s] do not contain test machine [%s]", expected, m)
}
示例7: TestListKeys
// Tests for Keys API
func (s *CloudAPIHTTPSuite) TestListKeys(c *gc.C) {
var expected []cloudapi.Key
k := s.createKey(c, testKeyName, testKey)
defer s.deleteKey(c, testKeyName)
resp, err := s.sendRequest("GET", path.Join(testUserAccount, "keys"), nil, nil)
c.Assert(err, gc.IsNil)
c.Assert(resp.StatusCode, gc.Equals, http.StatusOK)
assertJSON(c, resp, &expected)
for _, key := range expected {
if c.Check(&key, gc.DeepEquals, k) {
c.SucceedNow()
}
}
c.Fatalf("Obtained keys [%s] do not contain test key [%s]", expected, k)
}
示例8: TestUnbindMultiUnits
func (s *S) TestUnbindMultiUnits(c *gocheck.C) {
var calls int32
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
i := atomic.LoadInt32(&calls)
i++
atomic.StoreInt32(&calls, i)
w.WriteHeader(http.StatusNoContent)
}))
defer ts.Close()
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"})
instance := service.ServiceInstance{
Name: "my-mysql",
ServiceName: "mysql",
Teams: []string{s.team.Name},
Apps: []string{"painkiller"},
}
instance.Create()
defer s.conn.ServiceInstances().Remove(bson.M{"name": "my-mysql"})
a, err := createTestApp(s.conn, "painkiller", "", []string{s.team.Name})
c.Assert(err, gocheck.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
app.Provisioner.Provision(&a)
defer app.Provisioner.Destroy(&a)
app.Provisioner.AddUnits(&a, 1)
err = instance.UnbindApp(&a)
c.Assert(err, gocheck.IsNil)
ok := make(chan bool, 1)
go func() {
t := time.Tick(1)
for _ = <-t; atomic.LoadInt32(&calls) < 2; _ = <-t {
}
ok <- true
}()
select {
case <-ok:
c.SucceedNow()
case <-time.After(1 * time.Second):
c.Error("endpoint not called")
}
}
示例9: TestUnbindCallsTheUnbindMethodFromAPI
func (s *BindSuite) TestUnbindCallsTheUnbindMethodFromAPI(c *gocheck.C) {
var called int32
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "DELETE" && r.URL.Path == "/resources/my-mysql/hostname/10.10.10.1" {
atomic.StoreInt32(&called, 1)
}
}))
defer ts.Close()
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"})
instance := service.ServiceInstance{
Name: "my-mysql",
ServiceName: "mysql",
Teams: []string{s.team.Name},
Apps: []string{"painkiller"},
}
err = instance.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.ServiceInstances().Remove(bson.M{"name": "my-mysql"})
a, err := createTestApp(s.conn, "painkiller", "", []string{s.team.Name})
c.Assert(err, gocheck.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": a.Name})
app.Provisioner.Provision(&a)
defer app.Provisioner.Destroy(&a)
app.Provisioner.AddUnits(&a, 1)
err = instance.UnbindApp(&a)
c.Assert(err, gocheck.IsNil)
ch := make(chan bool)
go func() {
t := time.Tick(1)
for _ = <-t; atomic.LoadInt32(&called) == 0; _ = <-t {
}
ch <- true
}()
select {
case <-ch:
c.SucceedNow()
case <-time.After(1e9):
c.Errorf("Failed to call API after 1 second.")
}
}