本文整理匯總了Golang中github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-check.C.Logf方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Logf方法的具體用法?Golang C.Logf怎麽用?Golang C.Logf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-check.C
的用法示例。
在下文中一共展示了C.Logf方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: generateControllerExamples
func (s *ControllerSuite) generateControllerExamples(t *c.C) map[string]interface{} {
cmd := exec.Command(exec.DockerImage(imageURIs["controller-examples"]), "/bin/flynn-controller-examples")
cmd.Env = map[string]string{
"CONTROLLER_KEY": s.clusterConf(t).Key,
"SKIP_MIGRATE_DOMAIN": "true",
}
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()
t.Logf("stdout: %q", stdout.String())
t.Logf("stderr: %q", stderr.String())
t.Assert(err, c.IsNil)
var controllerExamples map[string]json.RawMessage
t.Assert(json.Unmarshal(stdout.Bytes(), &controllerExamples), c.IsNil)
examples := make(map[string]interface{}, len(controllerExamples))
for key, data := range controllerExamples {
example, err := unmarshalControllerExample(data)
t.Assert(err, c.IsNil)
examples[key] = example
}
return examples
}
示例2: TestLogFollow
func (s *CLISuite) TestLogFollow(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
t.Assert(app.flynn("run", "-d", "sh", "-c", "sleep 2 && for i in 1 2 3 4 5; do echo \"line $i\"; done"), Succeeds)
app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1}})
log := app.flynnCmd("log", "--raw-output", "--follow")
logStdout, err := log.StdoutPipe()
t.Assert(err, c.IsNil)
t.Assert(log.Start(), c.IsNil)
defer log.Process.Kill()
// use a goroutine + channel so we can timeout the stdout read
type line struct {
text string
err error
}
lines := make(chan line)
go func() {
buf := bufio.NewReader(logStdout)
for {
text, err := buf.ReadBytes('\n')
if err != nil {
if err != io.EOF {
lines <- line{"", err}
}
break
}
lines <- line{string(text), nil}
}
}()
readline := func() (string, error) {
select {
case l := <-lines:
if l.err != nil {
return "", fmt.Errorf("could not read log output: %s", l.err)
}
return l.text, nil
case <-time.After(5 * time.Second):
return "", errors.New("timed out waiting for log output")
}
}
var stderr bytes.Buffer
for i := 1; i < 6; i++ {
expected := fmt.Sprintf("line %d\n", i)
actual, err := readline()
if err != nil {
t.Logf("STDERR = %q", stderr.String())
}
t.Assert(err, c.IsNil)
t.Assert(actual, c.Equals, expected)
}
}
示例3: TestExecCrashingJob
func (s *HostSuite) TestExecCrashingJob(t *c.C) {
cluster := s.clusterClient(t)
for _, attach := range []bool{true, false} {
t.Logf("attach = %v", attach)
cmd := exec.CommandUsingCluster(cluster, exec.DockerImage(imageURIs["test-apps"]), "sh", "-c", "exit 1")
if attach {
cmd.Stdout = ioutil.Discard
cmd.Stderr = ioutil.Discard
}
t.Assert(cmd.Run(), c.DeepEquals, exec.ExitError(1))
}
}