本文整理汇总了Golang中launchpad/net/gocheck.C类的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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},
})
}
示例3: 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
}
示例4: 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()
}
示例5: TestExportEnvironmentsBackward
func (s *S) TestExportEnvironmentsBackward(c *gocheck.C) {
envNames := []string{
"TSURU_S3_ACCESS_KEY_ID", "TSURU_S3_SECRET_KEY",
"TSURU_APPNAME", "TSURU_HOST", "TSURU_S3_ENDPOINT",
"TSURU_S3_LOCATIONCONSTRAINT", "TSURU_S3_BUCKET",
"TSURU_APP_TOKEN",
}
app := App{Name: "moon", Platform: "opeth", Env: make(map[string]bind.EnvVar)}
for _, name := range envNames {
envVar := bind.EnvVar{Name: name, Value: name, Public: false}
if strings.HasPrefix(name, "TSURU_S3_") {
envVar.InstanceName = s3InstanceName
}
app.Env[name] = envVar
}
token, err := auth.CreateApplicationToken(app.Name)
c.Assert(err, gocheck.IsNil)
app.Env["TSURU_APP_TOKEN"] = bind.EnvVar{Name: "TSURU_APP_NAME", Value: token.Token}
err = s.conn.Apps().Insert(app)
c.Assert(err, gocheck.IsNil)
defer s.conn.Apps().Remove(bson.M{"name": app.Name})
ctx := action.BWContext{Params: []interface{}{&app}}
exportEnvironmentsAction.Backward(ctx)
copy, err := GetByName(app.Name)
c.Assert(err, gocheck.IsNil)
for _, name := range envNames {
if _, ok := copy.Env[name]; ok {
c.Errorf("Variable %q should be unexported, but it's still exported.", name)
}
}
_, err = auth.GetToken("bearer " + token.Token)
c.Assert(err, gocheck.Equals, auth.ErrInvalidToken)
}
示例6: 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)
}
示例7: TestParseGfxmode
func (*GrubTester) TestParseGfxmode(c *C.C) {
sw, sh := getPrimaryScreenBestResolution()
data := []struct {
v string
w, h uint16
}{
{"auto", sw, sh},
{"auto,800x600", sw, sh},
{"1024x768", 1024, 768},
{"1024x768x24", 1024, 768},
{"1024x768,800x600,auto", 1024, 768},
{"1024x768;800x600;auto", 1024, 768},
{"1024x768x24,800x600,auto", 1024, 768},
}
for _, d := range data {
w, h, _ := doParseGfxmode(d.v)
c.Check(w, C.Equals, d.w)
c.Check(h, C.Equals, d.h)
}
// test wrong format
_, _, err := doParseGfxmode("")
c.Check(err, C.NotNil)
_, _, err = doParseGfxmode("1024")
c.Check(err, C.NotNil)
_, _, err = doParseGfxmode("1024x")
c.Check(err, C.NotNil)
_, _, err = doParseGfxmode("autox24")
c.Check(err, C.NotNil)
}
示例8: 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)
}
示例9: start
func (s *localServer) start(c *gc.C, cred *identity.Credentials) {
// Set up the HTTP server.
if s.UseTLS {
s.Server = httptest.NewTLSServer(nil)
} else {
s.Server = httptest.NewServer(nil)
}
c.Assert(s.Server, gc.NotNil)
s.oldHandler = s.Server.Config.Handler
s.Mux = http.NewServeMux()
s.Server.Config.Handler = s.Mux
cred.URL = s.Server.URL
c.Logf("Started service at: %v", s.Server.URL)
s.Service = openstackservice.New(cred, identity.AuthUserPass)
s.Service.SetupHTTP(s.Mux)
s.restoreTimeouts = envtesting.PatchAttemptStrategies(openstack.ShortAttempt, openstack.StorageAttempt)
s.Service.Nova.SetAvailabilityZones(
nova.AvailabilityZone{Name: "test-unavailable"},
nova.AvailabilityZone{
Name: "test-available",
State: nova.AvailabilityZoneState{
Available: true,
},
},
)
}
示例10: 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)
}
示例11: 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`)
}
示例12: TestResolveNetworkNotPresent
func (s *localServerSuite) TestResolveNetworkNotPresent(c *gc.C) {
env := s.Prepare(c)
var notPresentNetwork = "no-network-with-this-label"
networkId, err := openstack.ResolveNetwork(env, notPresentNetwork)
c.Check(networkId, gc.Equals, "")
c.Assert(err, gc.ErrorMatches, `No networks exist with label "no-network-with-this-label"`)
}
示例13: TestResolveNetworkUUID
func (s *localServerSuite) TestResolveNetworkUUID(c *gc.C) {
env := s.Prepare(c)
var sampleUUID = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
networkId, err := openstack.ResolveNetwork(env, sampleUUID)
c.Assert(err, gc.IsNil)
c.Assert(networkId, gc.Equals, sampleUUID)
}
示例14: makeRequestToServicesHandler
func (s *ProvisionSuite) makeRequestToServicesHandler(c *gocheck.C) (*httptest.ResponseRecorder, *http.Request) {
request, err := http.NewRequest("GET", "/services", nil)
c.Assert(err, gocheck.IsNil)
request.Header.Set("Content-Type", "application/json")
recorder := httptest.NewRecorder()
return recorder, request
}
示例15: startReading
// startReading starts a goroutine receiving the lines out of the reader
// in the background and passing them to a created string channel. This
// will used in the assertions.
func startReading(c *gc.C, tailer *tailer.Tailer, reader *io.PipeReader, writer *io.PipeWriter) chan string {
linec := make(chan string)
// Start goroutine for reading.
go func() {
defer close(linec)
reader := bufio.NewReader(reader)
for {
line, err := reader.ReadString('\n')
switch err {
case nil:
linec <- line
case io.EOF:
return
default:
c.Fail()
}
}
}()
// Close writer when tailer is stopped or has an error. Tailer using
// components can do it the same way.
go func() {
tailer.Wait()
writer.Close()
}()
return linec
}