本文整理汇总了Golang中launchpad/net/gocheck.C.Assert方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Assert方法的具体用法?Golang C.Assert怎么用?Golang C.Assert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gocheck.C
的用法示例。
在下文中一共展示了C.Assert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestPrecheckInstanceAvailZonesUnsupported
func (t *localServerSuite) TestPrecheckInstanceAvailZonesUnsupported(c *gc.C) {
t.srv.Service.Nova.SetAvailabilityZones() // no availability zone support
env := t.Prepare(c)
placement := "zone=test-unknown"
err := env.PrecheckInstance("precise", constraints.Value{}, placement)
c.Assert(err, jc.Satisfies, jujuerrors.IsNotImplemented)
}
示例2: MakeConfig
// MakeConfig creates a functional environConfig for a test.
func MakeConfig(c *gc.C, attrs testing.Attrs) *environConfig {
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
return env.(*joyentEnviron).Ecfg()
}
示例3: TestMetaHooks
func (s *MetaSuite) TestMetaHooks(c *gc.C) {
meta, err := charm.ReadMeta(repoMeta("wordpress"))
c.Assert(err, gc.IsNil)
hooks := meta.Hooks()
expectedHooks := map[string]bool{
"install": true,
"start": true,
"config-changed": true,
"upgrade-charm": true,
"stop": true,
"cache-relation-joined": true,
"cache-relation-changed": true,
"cache-relation-departed": true,
"cache-relation-broken": true,
"db-relation-joined": true,
"db-relation-changed": true,
"db-relation-departed": true,
"db-relation-broken": true,
"logging-dir-relation-joined": true,
"logging-dir-relation-changed": true,
"logging-dir-relation-departed": true,
"logging-dir-relation-broken": true,
"monitoring-port-relation-joined": true,
"monitoring-port-relation-changed": true,
"monitoring-port-relation-departed": true,
"monitoring-port-relation-broken": true,
"url-relation-joined": true,
"url-relation-changed": true,
"url-relation-departed": true,
"url-relation-broken": true,
}
c.Assert(hooks, gc.DeepEquals, expectedHooks)
}
示例4: TestOpenPort
func (s *uniterSuite) TestOpenPort(c *gc.C) {
openedPorts := s.wordpressUnit.OpenedPorts()
c.Assert(openedPorts, gc.HasLen, 0)
args := params.EntitiesPorts{Entities: []params.EntityPort{
{Tag: "unit-mysql-0", Protocol: "tcp", Port: 1234},
{Tag: "unit-wordpress-0", Protocol: "udp", Port: 4321},
{Tag: "unit-foo-42", Protocol: "tcp", Port: 42},
}}
result, err := s.uniter.OpenPort(args)
c.Assert(err, gc.IsNil)
c.Assert(result, gc.DeepEquals, params.ErrorResults{
Results: []params.ErrorResult{
{apiservertesting.ErrUnauthorized},
{nil},
{apiservertesting.ErrUnauthorized},
},
})
// Verify the wordpressUnit's port is opened.
err = s.wordpressUnit.Refresh()
c.Assert(err, gc.IsNil)
openedPorts = s.wordpressUnit.OpenedPorts()
c.Assert(openedPorts, gc.DeepEquals, []instance.Port{
{Protocol: "udp", Number: 4321},
})
}
示例5: makeRequestWithManifest
func makeRequestWithManifest(manifest string, c *gocheck.C) (*httptest.ResponseRecorder, *http.Request) {
b := bytes.NewBufferString(manifest)
request, err := http.NewRequest("POST", "/services", b)
c.Assert(err, gocheck.IsNil)
recorder := httptest.NewRecorder()
return recorder, request
}
示例6: addRelation
func (s *uniterSuite) addRelation(c *gc.C, first, second string) *state.Relation {
eps, err := s.State.InferEndpoints([]string{first, second})
c.Assert(err, gc.IsNil)
rel, err := s.State.AddRelation(eps...)
c.Assert(err, gc.IsNil)
return rel
}
示例7: TestPrecheckInstanceInvalidInstanceType
func (s *localServerSuite) TestPrecheckInstanceInvalidInstanceType(c *gc.C) {
env := s.Open(c)
cons := constraints.MustParse("instance-type=m1.large")
placement := ""
err := env.PrecheckInstance("precise", cons, placement)
c.Assert(err, gc.ErrorMatches, `invalid Openstack flavour "m1.large" specified`)
}
示例8: assertCollected
// assertCollected reads lines from the string channel linec. It compares if
// those are the one passed with compare until a timeout. If the timeout is
// reached earlier than all lines are collected the assertion fails. The
// injection function allows to interrupt the processing with a function
// generating an error or a regular stopping during the tailing. In case the
// linec is closed due to stopping or an error only the values so far care
// compared. Checking the reason for termination is done in the test.
func assertCollected(c *gc.C, linec chan string, compare []string, injection func([]string)) {
if len(compare) == 0 {
return
}
timeout := time.After(testing.LongWait)
lines := []string{}
for {
select {
case line, ok := <-linec:
if ok {
lines = append(lines, line)
if injection != nil {
injection(lines)
}
if len(lines) == len(compare) {
// All data received.
c.Assert(lines, gc.DeepEquals, compare)
return
}
} else {
// linec closed after stopping or error.
c.Assert(lines, gc.DeepEquals, compare[:len(lines)])
return
}
case <-timeout:
if injection == nil {
c.Fatalf("timeout during tailer collection")
}
return
}
}
}
示例9: TestAPIAddresses
func (s *deployerSuite) TestAPIAddresses(c *gc.C) {
apiInfo := s.APIInfo(c)
addresses, err := s.st.APIAddresses()
c.Assert(err, gc.IsNil)
c.Assert(addresses, gc.DeepEquals, apiInfo.Addrs)
}
示例10: TestStop
func (s *notifyWorkerSuite) TestStop(c *gc.C) {
err := s.worker.Stop()
c.Assert(err, gc.IsNil)
// After stop, Wait should return right away
err = WaitShort(c, s.worker)
c.Assert(err, gc.IsNil)
}
示例11: TestNewCharmRevisionUpdaterAPIRefusesNonStateManager
func (s *charmVersionSuite) TestNewCharmRevisionUpdaterAPIRefusesNonStateManager(c *gc.C) {
anAuthoriser := s.authoriser
anAuthoriser.EnvironManager = false
endPoint, err := charmrevisionupdater.NewCharmRevisionUpdaterAPI(s.State, s.resources, anAuthoriser)
c.Assert(endPoint, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "permission denied")
}
示例12: TestGetCollection
func (s *ELBSuite) TestGetCollection(c *gocheck.C) {
manager := ELBManager{}
conn, coll := manager.collection()
defer conn.Close()
other := s.conn.Collection(s.cName)
c.Assert(coll.FullName, gocheck.Equals, other.FullName)
}
示例13: TestSubordinateWithoutContainerRelation
func (s *MetaSuite) TestSubordinateWithoutContainerRelation(c *gc.C) {
r := repoMeta("dummy")
hackYaml := ReadYaml(r)
hackYaml["subordinate"] = true
_, err := charm.ReadMeta(hackYaml.Reader())
c.Assert(err, gc.ErrorMatches, "subordinate charm \"dummy\" lacks \"requires\" relation with container scope")
}
示例14: TestPrecheckInstanceValidInstanceType
func (s *localServerSuite) TestPrecheckInstanceValidInstanceType(c *gc.C) {
env := s.Open(c)
cons := constraints.MustParse("instance-type=m1.small")
placement := ""
err := env.PrecheckInstance("precise", cons, placement)
c.Assert(err, gc.IsNil)
}
示例15: assertSecurityGroups
func assertSecurityGroups(c *gc.C, env environs.Environ, expected []string) {
novaClient := openstack.GetNovaClient(env)
groups, err := novaClient.ListSecurityGroups()
c.Assert(err, gc.IsNil)
for _, name := range expected {
found := false
for _, group := range groups {
if group.Name == name {
found = true
break
}
}
if !found {
c.Errorf("expected security group %q not found", name)
}
}
for _, group := range groups {
found := false
for _, name := range expected {
if group.Name == name {
found = true
break
}
}
if !found {
c.Errorf("existing security group %q is not expected", group.Name)
}
}
}