本文整理汇总了Golang中gopkg/in/check/v1.C.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Log方法的具体用法?Golang C.Log怎么用?Golang C.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *GitoliteSuite) SetUpTest(c *check.C) {
var err error
s.gitoliteHome, err = ioutil.TempDir("", "arv-git-httpd")
c.Assert(err, check.Equals, nil)
runGitolite := func(prog string, args ...string) {
c.Log(prog, " ", args)
cmd := exec.Command(prog, args...)
cmd.Dir = s.gitoliteHome
cmd.Env = append(os.Environ(), "HOME="+s.gitoliteHome)
diags, err := cmd.CombinedOutput()
c.Log(string(diags))
c.Assert(err, check.Equals, nil)
}
runGitolite("gitolite", "setup", "--admin", "root")
s.tmpRepoRoot = s.gitoliteHome + "/repositories"
s.Config = &config{
Addr: ":0",
GitCommand: "/usr/share/gitolite3/gitolite-shell",
Root: s.tmpRepoRoot,
}
s.IntegrationSuite.SetUpTest(c)
// Install the gitolite hooks in the bare repo we made in
// (*IntegrationTest)SetUpTest() -- see 2.2.4 at
// http://gitolite.com/gitolite/gitolite.html
runGitolite("gitolite", "setup")
os.Setenv("GITOLITE_HTTP_HOME", s.gitoliteHome)
os.Setenv("GL_BYPASS_ACCESS_CHECKS", "1")
}
示例2: TestFlagsUsage
func (*ArgsSuite) TestFlagsUsage(c *gc.C) {
for i, test := range []struct {
message string
defaultValue []string
args []string
expectedValue []string
}{{
message: "nil default and no arg",
}, {
message: "default value and not set by args",
defaultValue: []string{"foo", "bar"},
expectedValue: []string{"foo", "bar"},
}, {
message: "no value set by args",
args: []string{"--value", "foo,bar"},
expectedValue: []string{"foo", "bar"},
}, {
message: "default value and set by args",
defaultValue: []string{"omg"},
args: []string{"--value", "foo,bar"},
expectedValue: []string{"foo", "bar"},
}} {
c.Log(fmt.Sprintf("%v: %s", i, test.message))
f := gnuflag.NewFlagSet("test", gnuflag.ContinueOnError)
f.SetOutput(ioutil.Discard)
var value []string
f.Var(cmd.NewStringsValue(test.defaultValue, &value), "value", "help")
err := f.Parse(false, test.args)
c.Check(err, gc.IsNil)
c.Check(value, gc.DeepEquals, test.expectedValue)
}
}
示例3: TestMergeIds
func (s *ActionSuite) TestMergeIds(c *gc.C) {
var tests = []struct {
changes string
adds string
removes string
expected string
}{
{changes: "", adds: "a0,a1", removes: "", expected: "a0,a1"},
{changes: "a0,a1", adds: "", removes: "a0", expected: "a1"},
{changes: "a0,a1", adds: "a2", removes: "a0", expected: "a1,a2"},
{changes: "", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
{changes: "", adds: "a0,a1,a2", removes: "a0,a1,a2", expected: ""},
{changes: "a0", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
{changes: "a1", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
{changes: "a2", adds: "a0,a1,a2", removes: "a0,a2", expected: "a1"},
{changes: "a3,a4", adds: "a1,a4,a5", removes: "a1,a3", expected: "a4,a5"},
{changes: "a0,a1,a2", adds: "a1,a4,a5", removes: "a1,a3", expected: "a0,a2,a4,a5"},
}
prefix := state.DocID(s.State, "")
for ix, test := range tests {
updates := mapify(prefix, test.adds, test.removes)
changes := sliceify("", test.changes)
expected := sliceify("", test.expected)
c.Log(fmt.Sprintf("test number %d %#v", ix, test))
err := state.WatcherMergeIds(s.State, &changes, updates, state.ActionNotificationIdToActionId)
c.Assert(err, jc.ErrorIsNil)
c.Assert(changes, jc.SameContents, expected)
}
}
示例4: TestNewContextRootLevel
func (*ContextSuite) TestNewContextRootLevel(c *gc.C) {
for i, test := range []struct {
level loggo.Level
expected loggo.Level
}{{
level: loggo.UNSPECIFIED,
expected: loggo.WARNING,
}, {
level: loggo.DEBUG,
expected: loggo.DEBUG,
}, {
level: loggo.INFO,
expected: loggo.INFO,
}, {
level: loggo.WARNING,
expected: loggo.WARNING,
}, {
level: loggo.ERROR,
expected: loggo.ERROR,
}, {
level: loggo.CRITICAL,
expected: loggo.CRITICAL,
}, {
level: loggo.Level(42),
expected: loggo.WARNING,
}} {
c.Log("%d: %s", i, test.level)
context := loggo.NewContext(test.level)
cfg := context.Config()
c.Check(cfg, gc.HasLen, 1)
value, found := cfg[""]
c.Check(found, gc.Equals, true)
c.Check(value, gc.Equals, test.expected)
}
}
示例5: TestClientModelUsers
func (s *clientSuite) TestClientModelUsers(c *gc.C) {
client := s.APIState.Client()
cleanup := api.PatchClientFacadeCall(client,
func(request string, paramsIn interface{}, response interface{}) error {
c.Assert(paramsIn, gc.IsNil)
if response, ok := response.(*params.ModelUserInfoResults); ok {
response.Results = []params.ModelUserInfoResult{
{Result: ¶ms.ModelUserInfo{UserName: "one"}},
{Result: ¶ms.ModelUserInfo{UserName: "two"}},
{Result: ¶ms.ModelUserInfo{UserName: "three"}},
}
} else {
c.Log("wrong output structure")
c.Fail()
}
return nil
},
)
defer cleanup()
obtained, err := client.ModelUserInfo()
c.Assert(err, jc.ErrorIsNil)
c.Assert(obtained, jc.DeepEquals, []params.ModelUserInfo{
{UserName: "one"},
{UserName: "two"},
{UserName: "three"},
})
}
示例6: TestString
func (*ArgsSuite) TestString(c *gc.C) {
for i, test := range []struct {
message string
target []string
expected string
}{{
message: "null",
expected: "",
}, {
message: "empty",
target: []string{},
expected: "",
}, {
message: "single value",
target: []string{"foo"},
expected: "foo",
}, {
message: "multiple values",
target: []string{"foo", "bar", "baz"},
expected: "foo,bar,baz",
}} {
c.Log(fmt.Sprintf("%v: %s", i, test.message))
var temp []string
value := cmd.NewStringsValue(test.target, &temp)
c.Assert(value.String(), gc.Equals, test.expected)
}
}
示例7: TestInvalidHTTPMethods
func (s *backupsSuite) TestInvalidHTTPMethods(c *gc.C) {
url := s.backupURL(c)
for _, method := range []string{"POST", "DELETE", "OPTIONS"} {
c.Log("testing HTTP method: " + method)
s.checkInvalidMethod(c, method, url)
}
}
示例8: assertAgentSetsToolsVersion
func (s *MachineSuite) assertAgentSetsToolsVersion(c *gc.C, job state.MachineJob) {
vers := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
vers.Minor++
m, _, _ := s.primeAgentVersion(c, vers, job)
a := s.newAgent(c, m)
go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
defer func() { c.Check(a.Stop(), jc.ErrorIsNil) }()
timeout := time.After(coretesting.LongWait)
for done := false; !done; {
select {
case <-timeout:
c.Fatalf("timeout while waiting for agent version to be set")
case <-time.After(coretesting.ShortWait):
c.Log("Refreshing")
err := m.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Log("Fetching agent tools")
agentTools, err := m.AgentTools()
c.Assert(err, jc.ErrorIsNil)
c.Logf("(%v vs. %v)", agentTools.Version, jujuversion.Current)
if agentTools.Version.Minor != jujuversion.Current.Minor {
continue
}
c.Assert(agentTools.Version.Number, gc.DeepEquals, jujuversion.Current)
done = true
}
}
}
示例9: TestTimeoutArgParsing
func (*RunSuite) TestTimeoutArgParsing(c *gc.C) {
for i, test := range []struct {
message string
args []string
errMatch string
timeout time.Duration
}{{
message: "default time",
args: []string{"--all", "sudo reboot"},
timeout: 5 * time.Minute,
}, {
message: "invalid time",
args: []string{"--timeout=foo", "--all", "sudo reboot"},
errMatch: `invalid value "foo" for flag --timeout: time: invalid duration foo`,
}, {
message: "two hours",
args: []string{"--timeout=2h", "--all", "sudo reboot"},
timeout: 2 * time.Hour,
}, {
message: "3 minutes 30 seconds",
args: []string{"--timeout=3m30s", "--all", "sudo reboot"},
timeout: (3 * time.Minute) + (30 * time.Second),
}} {
c.Log(fmt.Sprintf("%v: %s", i, test.message))
cmd := &runCommand{}
runCmd := modelcmd.Wrap(cmd)
testing.TestInit(c, runCmd, test.args, test.errMatch)
if test.errMatch == "" {
c.Check(cmd.timeout, gc.Equals, test.timeout)
}
}
}
示例10: TestFullSync
// Test full node sync.
func (s *ReconSuite) TestFullSync(c *gc.C) {
ptree1, cleanup, err := s.Factory()
c.Assert(err, gc.IsNil)
defer cleanup()
ptree2, cleanup, err := s.Factory()
c.Assert(err, gc.IsNil)
defer cleanup()
ptree1.Insert(cf.Zi(cf.P_SKS, 65537))
ptree1.Insert(cf.Zi(cf.P_SKS, 65539))
root, _ := ptree1.Root()
c.Log("peer1:", recon.MustElements(root))
ptree2.Insert(cf.Zi(cf.P_SKS, 65537))
ptree2.Insert(cf.Zi(cf.P_SKS, 65541))
root, _ = ptree2.Root()
c.Log("peer2:", recon.MustElements(root))
port1, port2 := portPair(c)
peer1 := s.newPeer(port1, port2, recon.PeerModeGossipOnly, ptree1)
peer2 := s.newPeer(port2, port1, recon.PeerModeServeOnly, ptree2)
err = s.pollRootConvergence(c, peer1, peer2, ptree1, ptree2)
c.Assert(err, gc.IsNil)
}
示例11: SetUpTest
func (cs *ConnSuite) SetUpTest(c *gc.C) {
c.Log("SetUpTest")
cs.policy = statetesting.MockPolicy{
GetStorageProviderRegistry: func() (storage.ProviderRegistry, error) {
return dummy.StorageProviders(), nil
},
}
cs.StateSuite.NewPolicy = func(*state.State) state.Policy {
return &cs.policy
}
cs.StateSuite.SetUpTest(c)
cs.modelTag = cs.State.ModelTag()
jujuDB := cs.MgoSuite.Session.DB("juju")
cs.annotations = jujuDB.C("annotations")
cs.charms = jujuDB.C("charms")
cs.machines = jujuDB.C("machines")
cs.instanceData = jujuDB.C("instanceData")
cs.relations = jujuDB.C("relations")
cs.services = jujuDB.C("applications")
cs.units = jujuDB.C("units")
cs.controllers = jujuDB.C("controllers")
c.Log("SetUpTest done")
}
示例12: diffStrings
func diffStrings(c *gc.C, value, expected string) {
// If only Go had a diff library.
vlines := strings.Split(value, "\n")
elines := strings.Split(expected, "\n")
vsize := len(vlines)
esize := len(elines)
if vsize < 2 || esize < 2 {
return
}
smaller := elines
if vsize < esize {
smaller = vlines
}
for i := range smaller {
vline := vlines[i]
eline := elines[i]
if vline != eline {
c.Logf("first mismatched line (%d/%d):", i, len(smaller))
c.Log("expected: " + eline)
c.Log("got: " + vline)
break
}
}
}
示例13: TestLabsAutochartistPattern
func (ts *TestLabsSuite) TestLabsAutochartistPattern(c *check.C) {
p, err := ts.c.AutochartistPattern()
c.Assert(err, check.IsNil)
c.Log(p)
c.Assert(p.Provider, check.Equals, "autochartist")
c.Assert(len(p.Signals) > 0, check.Equals, true)
}
示例14: TestLabsCommitmentsOfTraders
func (ts *TestLabsSuite) TestLabsCommitmentsOfTraders(c *check.C) {
instrument := "eur_usd"
cot, err := ts.c.CommitmentsOfTraders(instrument)
c.Assert(err, check.IsNil)
c.Log(cot)
c.Assert(len(cot) > 0, check.Equals, true)
}
示例15: TestUnshareEnvironmentThreeUsers
func (s *clientSuite) TestUnshareEnvironmentThreeUsers(c *gc.C) {
client := s.APIState.Client()
missingUser := s.Factory.MakeEnvUser(c, nil)
localUser := s.Factory.MakeUser(c, nil)
newUserTag := names.NewUserTag("[email protected]")
cleanup := api.PatchClientFacadeCall(client,
func(request string, paramsIn interface{}, response interface{}) error {
if users, ok := paramsIn.(params.ModifyEnvironUsers); ok {
c.Assert(users.Changes, gc.HasLen, 3)
c.Assert(string(users.Changes[0].Action), gc.Equals, string(params.RemoveEnvUser))
c.Assert(users.Changes[0].UserTag, gc.Equals, missingUser.UserTag().String())
c.Assert(string(users.Changes[1].Action), gc.Equals, string(params.RemoveEnvUser))
c.Assert(users.Changes[1].UserTag, gc.Equals, localUser.UserTag().String())
c.Assert(string(users.Changes[2].Action), gc.Equals, string(params.RemoveEnvUser))
c.Assert(users.Changes[2].UserTag, gc.Equals, newUserTag.String())
} else {
c.Log("wrong input structure")
c.Fail()
}
if result, ok := response.(*params.ErrorResults); ok {
err := ¶ms.Error{Message: "error unsharing user"}
*result = params.ErrorResults{Results: []params.ErrorResult{{Error: err}, {Error: nil}, {Error: nil}}}
} else {
c.Log("wrong output structure")
c.Fail()
}
return nil
},
)
defer cleanup()
err := client.UnshareEnvironment(missingUser.UserTag(), localUser.UserTag(), newUserTag)
c.Assert(err, gc.ErrorMatches, "error unsharing user")
}