本文整理汇总了Golang中gopkg/in/check/v1.C类的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestRemove
func (s *initSystemSuite) TestRemove(c *gc.C) {
s.addService("jujud-machine-0", "inactive")
s.addListResponse()
err := s.service.Remove()
c.Assert(err, jc.ErrorIsNil)
s.stub.CheckCalls(c, []testing.StubCall{{
FuncName: "RunCommand",
Args: []interface{}{
listCmdArg,
},
}, {
FuncName: "DisableUnitFiles",
Args: []interface{}{
[]string{s.name + ".service"},
false,
},
}, {
FuncName: "Reload",
}, {
FuncName: "RemoveAll",
Args: []interface{}{
fmt.Sprintf("%s/init/%s", s.dataDir, s.name),
},
}, {
FuncName: "Close",
}})
}
示例2: SetUpTest
func (s *ListSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.SetFeatureFlags(feature.JES)
s.store = configstore.NewMem()
var envList = []struct {
name string
serverUUID string
envUUID string
}{
{
name: "test1",
serverUUID: "test1-uuid",
envUUID: "test1-uuid",
}, {
name: "test2",
serverUUID: "test1-uuid",
envUUID: "test2-uuid",
}, {
name: "test3",
envUUID: "test3-uuid",
},
}
for _, env := range envList {
info := s.store.CreateInfo(env.name)
info.SetAPIEndpoint(configstore.APIEndpoint{
Addresses: []string{"localhost"},
CACert: testing.CACert,
EnvironUUID: env.envUUID,
ServerUUID: env.serverUUID,
})
err := info.Write()
c.Assert(err, jc.ErrorIsNil)
}
}
示例3: TestListVolumes
func (s *storageSuite) TestListVolumes(c *gc.C) {
s.storageClient.ListBlobsFunc = func(
container string,
params azurestorage.ListBlobsParameters,
) (azurestorage.BlobListResponse, error) {
return azurestorage.BlobListResponse{
Blobs: []azurestorage.Blob{{
Name: "volume-1.vhd",
Properties: azurestorage.BlobProperties{
ContentLength: 1024 * 1024, // 1MiB
},
}, {
Name: "volume-0.vhd",
Properties: azurestorage.BlobProperties{
ContentLength: 1024 * 1024 * 1024 * 1024, // 1TiB
},
}, {
Name: "junk.vhd",
}, {
Name: "volume",
}},
}, nil
}
volumeSource := s.volumeSource(c)
volumeIds, err := volumeSource.ListVolumes()
c.Assert(err, jc.ErrorIsNil)
s.storageClient.CheckCallNames(c, "NewClient", "ListBlobs")
s.storageClient.CheckCall(
c, 0, "NewClient", fakeStorageAccount, fakeStorageAccountKey,
"core.windows.net", azurestorage.DefaultAPIVersion, true,
)
s.storageClient.CheckCall(c, 1, "ListBlobs", "datavhds", azurestorage.ListBlobsParameters{})
c.Assert(volumeIds, jc.DeepEquals, []string{"volume-1", "volume-0"})
}
示例4: TestGetRejectsWrongEnvUUIDPath
func (s *charmsSuite) TestGetRejectsWrongEnvUUIDPath(c *gc.C) {
url := s.charmsURL(c, "url=local:quantal/dummy-1&file=revision")
url.Path = "/environment/dead-beef-123456/charms"
resp, err := s.authRequest(c, "GET", url.String(), "", nil)
c.Assert(err, jc.ErrorIsNil)
s.assertErrorResponse(c, resp, http.StatusNotFound, `unknown environment: "dead-beef-123456"`)
}
示例5: TestOutputReporter
func (s *SelfSuite) TestOutputReporter(c *gc.C) {
manifold := dependency.SelfManifold(s.engine)
var reporter dependency.Reporter
err := manifold.Output(s.engine, &reporter)
c.Check(err, jc.ErrorIsNil)
c.Check(reporter, gc.Equals, s.engine)
}
示例6: TestDecodeCheckInvalidSignature
func (s *decodeSuite) TestDecodeCheckInvalidSignature(c *gc.C) {
r := bytes.NewReader([]byte(invalidClearsignInput + signSuffix))
_, err := simplestreams.DecodeCheckSignature(r, testSigningKey)
c.Assert(err, gc.Not(gc.IsNil))
_, ok := err.(*simplestreams.NotPGPSignedError)
c.Assert(ok, jc.IsFalse)
}
示例7: TestAliasColumnSetTableName
func (s *ColumnSuite) TestAliasColumnSetTableName(c *gc.C) {
col := Alias("foo", SqlFunc("max", table1Col1))
// should always error
err := col.setTableName("test")
c.Assert(err, gc.NotNil)
}
示例8: TestWorkerPathsWindows
func (s *PathsSuite) TestWorkerPathsWindows(c *gc.C) {
s.PatchValue(&os.HostOS, func() os.OSType { return os.Windows })
dataDir := c.MkDir()
unitTag := names.NewUnitTag("some-service/323")
worker := "some-worker"
paths := uniter.NewWorkerPaths(dataDir, unitTag, worker)
relData := relPathFunc(dataDir)
relAgent := relPathFunc(relData("agents", "unit-some-service-323"))
c.Assert(paths, jc.DeepEquals, uniter.Paths{
ToolsDir: relData("tools/unit-some-service-323"),
Runtime: uniter.RuntimePaths{
JujuRunSocket: `\\.\pipe\unit-some-service-323-some-worker-run`,
JujucServerSocket: `\\.\pipe\unit-some-service-323-some-worker-agent`,
},
State: uniter.StatePaths{
BaseDir: relAgent(),
CharmDir: relAgent("charm"),
OperationsFile: relAgent("state", "uniter"),
RelationsDir: relAgent("state", "relations"),
BundlesDir: relAgent("state", "bundles"),
DeployerDir: relAgent("state", "deployer"),
StorageDir: relAgent("state", "storage"),
MetricsSpoolDir: relAgent("state", "spool", "metrics"),
},
})
}
示例9: TestOther
func (s *PathsSuite) TestOther(c *gc.C) {
s.PatchValue(&os.HostOS, func() os.OSType { return os.Unknown })
dataDir := c.MkDir()
unitTag := names.NewUnitTag("some-service/323")
paths := uniter.NewPaths(dataDir, unitTag)
relData := relPathFunc(dataDir)
relAgent := relPathFunc(relData("agents", "unit-some-service-323"))
c.Assert(paths, jc.DeepEquals, uniter.Paths{
ToolsDir: relData("tools/unit-some-service-323"),
Runtime: uniter.RuntimePaths{
JujuRunSocket: relAgent("run.socket"),
JujucServerSocket: "@" + relAgent("agent.socket"),
},
State: uniter.StatePaths{
BaseDir: relAgent(),
CharmDir: relAgent("charm"),
OperationsFile: relAgent("state", "uniter"),
RelationsDir: relAgent("state", "relations"),
BundlesDir: relAgent("state", "bundles"),
DeployerDir: relAgent("state", "deployer"),
StorageDir: relAgent("state", "storage"),
MetricsSpoolDir: relAgent("state", "spool", "metrics"),
},
})
}
示例10: TestSelectGetAllCompoundIndex
func (s *RethinkSuite) TestSelectGetAllCompoundIndex(c *test.C) {
// Ensure table + database exist
DBCreate("test").Exec(session)
DB("test").TableDrop("TableCompound").Exec(session)
DB("test").TableCreate("TableCompound").Exec(session)
write, err := DB("test").Table("TableCompound").IndexCreateFunc("full_name", func(row Term) interface{} {
return []interface{}{row.Field("first_name"), row.Field("last_name")}
}).RunWrite(session)
DB("test").Table("TableCompound").IndexWait().Exec(session)
c.Assert(err, test.IsNil)
c.Assert(write.Created, test.Equals, 1)
// Insert rows
DB("test").Table("TableCompound").Insert(nameList).Exec(session)
// Test query
var response interface{}
query := DB("test").Table("TableCompound").GetAllByIndex("full_name", []interface{}{"John", "Smith"})
res, err := query.Run(session)
c.Assert(err, test.IsNil)
err = res.One(&response)
c.Assert(err, test.IsNil)
c.Assert(response, jsonEquals, map[string]interface{}{"id": 1, "first_name": "John", "last_name": "Smith", "gender": "M"})
res.Close()
}
示例11: SetUpTest
func (s *credentialsSuite) SetUpTest(c *gc.C) {
s.IsolationSuite.SetUpTest(c)
var err error
s.provider, err = environs.Provider("gce")
c.Assert(err, jc.ErrorIsNil)
}
示例12: TestReportError
func (s *ReportSuite) TestReportError(c *gc.C) {
s.fix.run(c, func(engine *dependency.Engine) {
mh1 := newManifoldHarness("missing")
manifold := mh1.Manifold()
err := engine.Install("task", manifold)
c.Assert(err, jc.ErrorIsNil)
mh1.AssertNoStart(c)
workertest.CleanKill(c, engine)
report := engine.Report()
c.Check(report, jc.DeepEquals, map[string]interface{}{
"state": "stopped",
"error": nil,
"manifolds": map[string]interface{}{
"task": map[string]interface{}{
"state": "stopped",
"error": dependency.ErrMissing,
"inputs": []string{"missing"},
"resource-log": []map[string]interface{}{{
"name": "missing",
"type": "<nil>",
"error": dependency.ErrMissing,
}},
"report": (map[string]interface{})(nil),
},
},
})
})
}
示例13: TestInstallCommandsLogfile
func (s *initSystemSuite) TestInstallCommandsLogfile(c *gc.C) {
name := "jujud-machine-0"
s.conf.Logfile = "/var/log/juju/machine-0.log"
service := s.newService(c)
commands, err := service.InstallCommands()
c.Assert(err, jc.ErrorIsNil)
test := systemdtesting.WriteConfTest{
Service: name,
DataDir: s.dataDir,
Expected: strings.Replace(
s.newConfStr(name),
"ExecStart=/var/lib/juju/bin/jujud machine-0",
"ExecStart=/var/lib/juju/init/jujud-machine-0/exec-start.sh",
-1),
Script: `
# Set up logging.
touch '/var/log/juju/machine-0.log'
chown syslog:syslog '/var/log/juju/machine-0.log'
chmod 0600 '/var/log/juju/machine-0.log'
exec >> '/var/log/juju/machine-0.log'
exec 2>&1
# Run the script.
`[1:] + jujud + " machine-0",
}
test.CheckCommands(c, commands)
}
示例14: SetUpTest
func (s *initSystemSuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
dataDir, err := paths.DataDir("vivid")
c.Assert(err, jc.ErrorIsNil)
s.dataDir = dataDir
// Patch things out.
s.ch = systemd.PatchNewChan(s)
s.stub = &testing.Stub{}
s.conn = systemd.PatchNewConn(s, s.stub)
s.fops = systemd.PatchFileOps(s, s.stub)
s.exec = systemd.PatchExec(s, s.stub)
// Set up the service.
tagStr := "machine-0"
tag, err := names.ParseTag(tagStr)
c.Assert(err, jc.ErrorIsNil)
s.tag = tag
s.name = "jujud-" + tagStr
s.conf = common.Conf{
Desc: "juju agent for " + tagStr,
ExecStart: jujud + " " + tagStr,
}
s.service = s.newService(c)
// Reset any incidental calls.
s.stub.ResetCalls()
}
示例15: SetUpTest
func (s *DirectorySuite) SetUpTest(c *gc.C) {
s.BaseSuite.SetUpTest(c)
s.containerDir = c.MkDir()
s.PatchValue(&container.ContainerDir, s.containerDir)
s.removedDir = c.MkDir()
s.PatchValue(&container.RemovedContainerDir, s.removedDir)
}