本文整理匯總了Golang中github.com/flynn/go-check.Not函數的典型用法代碼示例。如果您正苦於以下問題:Golang Not函數的具體用法?Golang Not怎麽用?Golang Not使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Not函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testApp
func testApp(s *CLISuite, t *c.C, remote string) {
app := s.newGitRepo(t, "")
name := random.String(30)
flynnRemote := fmt.Sprintf("%s\t%s/%s.git (push)", remote, s.clusterConf(t).GitURL, name)
if remote == "flynn" {
t.Assert(app.flynn("create", "-y", name), Outputs, fmt.Sprintf("Created %s\n", name))
} else {
t.Assert(app.flynn("create", "-r", remote, "-y", name), Outputs, fmt.Sprintf("Created %s\n", name))
}
t.Assert(app.flynn("apps"), SuccessfulOutputContains, name)
t.Assert(app.flynn("-c", "default", "apps"), SuccessfulOutputContains, name)
if remote == "" {
t.Assert(app.git("remote", "-v"), c.Not(SuccessfulOutputContains), flynnRemote)
} else {
t.Assert(app.git("remote", "-v"), SuccessfulOutputContains, flynnRemote)
}
// make sure flynn components are listed
t.Assert(app.flynn("apps"), SuccessfulOutputContains, "router")
t.Assert(app.flynn("-c", "default", "apps"), SuccessfulOutputContains, "router")
// flynn delete
if remote == "flynn" {
t.Assert(app.flynn("delete", "--yes"), Succeeds)
} else {
if remote == "" {
t.Assert(app.flynn("-a", name, "delete", "--yes", "-r", remote), Succeeds)
} else {
t.Assert(app.flynn("delete", "--yes", "-r", remote), Succeeds)
}
}
t.Assert(app.git("remote", "-v"), c.Not(SuccessfulOutputContains), flynnRemote)
}
示例2: TestReleaseRollback
func (s *CLISuite) TestReleaseRollback(t *c.C) {
// create an app and release it
r := s.newGitRepo(t, "http")
app := "release-rollback-" + random.String(8)
t.Assert(r.flynn("create", app), Succeeds)
t.Assert(r.git("push", "flynn", "master"), Succeeds)
// check that rollback fails when there's only a single release
res := r.flynn("release", "rollback", "--yes")
t.Assert(res, c.Not(Succeeds))
// create a second release
t.Assert(r.git("commit", "--allow-empty", "--message", "empty commit"), Succeeds)
t.Assert(r.git("push", "flynn", "master"), Succeeds)
// get the releases
client := s.controllerClient(t)
releases, err := client.AppReleaseList(app)
t.Assert(err, c.IsNil)
t.Assert(releases, c.HasLen, 2)
// rollback to the second release
res = r.flynn("release", "rollback", "--yes")
t.Assert(res, Succeeds)
// revert rollback
res = r.flynn("release", "rollback", "--yes", releases[0].ID)
t.Assert(res, Succeeds)
// check that attempting to rollback to the current release fails
res = r.flynn("release", "rollback", "--yes", releases[0].ID)
t.Assert(res, c.Not(Succeeds))
}
示例3: TestBackup
func (s *ControllerSuite) TestBackup(t *c.C) {
client := s.controllerClient(t)
out, err := client.Backup()
t.Assert(err, c.IsNil)
defer out.Close()
data := make(map[string][]byte)
tr := tar.NewReader(out)
for {
h, err := tr.Next()
if err == io.EOF {
break
}
t.Assert(err, c.IsNil)
b := make([]byte, h.Size)
_, err = tr.Read(b)
t.Assert(err, c.IsNil)
_, filename := filepath.Split(h.Name)
data[filename] = b
}
sql, ok := data["postgres.sql.gz"]
t.Assert(ok, c.Equals, true)
t.Assert(len(sql) > 0, c.Equals, true)
flynn, ok := data["flynn.json"]
t.Assert(ok, c.Equals, true)
var apps map[string]*ct.ExpandedFormation
t.Assert(json.Unmarshal(flynn, &apps), c.IsNil)
for _, name := range []string{"postgres", "discoverd", "flannel", "controller"} {
ef, ok := apps[name]
t.Assert(ok, c.Equals, true)
t.Assert(ef.App, c.Not(c.IsNil))
t.Assert(ef.Release, c.Not(c.IsNil))
t.Assert(ef.Processes, c.Not(c.IsNil))
t.Assert(ef.App.Name, c.Equals, name)
}
}
示例4: TestMeta
func (s *CLISuite) TestMeta(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
t.Assert(app.flynn("meta", "set", "META_TEST=var", "SECOND_VAL=2"), Succeeds)
t.Assert(app.flynn("meta").Output, Matches, `META_TEST *var`)
t.Assert(app.flynn("meta").Output, Matches, `SECOND_VAL *2`)
// test that unset can remove all meta tags
t.Assert(app.flynn("meta", "unset", "META_TEST", "SECOND_VAL"), Succeeds)
t.Assert(app.flynn("meta").Output, c.Not(Matches), `META_TEST *var`)
t.Assert(app.flynn("meta").Output, c.Not(Matches), `SECOND_VAL *2`)
}
示例5: TestCluster
func (s *CLISuite) TestCluster(t *c.C) {
// use a custom flynnrc to avoid disrupting other tests
file, err := ioutil.TempFile("", "")
t.Assert(err, c.IsNil)
flynn := func(cmdArgs ...string) *CmdResult {
cmd := exec.Command(args.CLI, cmdArgs...)
cmd.Env = flynnEnv(file.Name())
return run(t, cmd)
}
// cluster add
t.Assert(flynn("cluster", "add", "--no-git", "foo", "https://controller.foo.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster"), SuccessfulOutputContains, "foo")
t.Assert(flynn("cluster", "add", "--no-git", "-p", "KGCENkp53YF5OvOKkZIry71+czFRkSw2ZdMszZ/0ljs=", "test", "https://controller.test.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster"), SuccessfulOutputContains, "test")
t.Assert(flynn("cluster", "add", "-f", "--no-git", "-p", "KGCENkp53YF5OvOKkZIry71+czFRkSw2ZdMszZ/0ljs=", "test", "https://controller.test.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster"), SuccessfulOutputContains, "test")
t.Assert(flynn("cluster", "add", "-f", "-d", "--no-git", "-p", "KGCENkp53YF5OvOKkZIry71+czFRkSw2ZdMszZ/0ljs=", "test", "https://controller.test.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster"), SuccessfulOutputContains, "test")
// make sure the cluster is present in the config
cfg, err := config.ReadFile(file.Name())
t.Assert(err, c.IsNil)
t.Assert(cfg.Default, c.Equals, "test")
t.Assert(cfg.Clusters, c.HasLen, 2)
t.Assert(cfg.Clusters[0].Name, c.Equals, "foo")
t.Assert(cfg.Clusters[1].Name, c.Equals, "test")
// overwriting with a conflicting name and a different conflicting url should error
conflict := flynn("cluster", "add", "-f", "--no-git", "foo", "https://controller.test.example.com", "e09dc5301d72be755a3d666f617c4600")
t.Assert(conflict, c.Not(Succeeds))
t.Assert(conflict, OutputContains, "conflict with")
// overwriting (without --force) should not work
t.Assert(flynn("cluster", "add", "test", "foo", "bar"), c.Not(Succeeds))
t.Assert(flynn("cluster"), SuccessfulOutputContains, "test")
t.Assert(flynn("cluster"), SuccessfulOutputContains, "(default)")
// change default cluster
t.Assert(flynn("cluster", "default", "test"), SuccessfulOutputContains, "\"test\" is now the default cluster.")
t.Assert(flynn("cluster", "default", "missing"), OutputContains, "Cluster \"missing\" does not exist and cannot be set as default.")
t.Assert(flynn("cluster", "default"), SuccessfulOutputContains, "test")
cfg, err = config.ReadFile(file.Name())
t.Assert(err, c.IsNil)
t.Assert(cfg.Default, c.Equals, "test")
// cluster remove
t.Assert(flynn("cluster", "remove", "test"), Succeeds)
t.Assert(flynn("cluster"), c.Not(SuccessfulOutputContains), "test")
cfg, err = config.ReadFile(file.Name())
t.Assert(err, c.IsNil)
t.Assert(cfg.Clusters, c.HasLen, 1)
t.Assert(flynn("cluster", "remove", "foo"), Succeeds)
// cluster remove default and set next available
t.Assert(flynn("cluster", "add", "-d", "--no-git", "-p", "KGCENkp53YF5OvOKkZIry71+czFRkSw2ZdMszZ/0ljs=", "test", "https://controller.test.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster", "add", "--no-git", "-p", "KGCENkp53YF5OvOKkZIry71+czFRkSw2ZdMszZ/0ljs=", "next", "https://controller.next.example.com", "e09dc5301d72be755a3d666f617c4600"), Succeeds)
t.Assert(flynn("cluster", "remove", "test"), SuccessfulOutputContains, "Cluster \"test\" removed and \"next\" is now the default cluster.")
t.Assert(flynn("cluster", "default"), SuccessfulOutputContains, "next")
}
示例6: TestRun
func (s *CLISuite) TestRun(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
// this shouldn't be logged
t.Assert(app.sh("echo foo"), Outputs, "foo\n")
// drain the events
app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1, ct.JobStateDown: 1}})
// this should be logged due to the --enable-log flag
t.Assert(app.flynn("run", "--enable-log", "echo", "hello"), Outputs, "hello\n")
app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1, ct.JobStateDown: 1}})
detached := app.flynn("run", "-d", "echo", "world")
t.Assert(detached, Succeeds)
t.Assert(detached, c.Not(Outputs), "world\n")
id := strings.TrimSpace(detached.Output)
jobID := app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1, ct.JobStateDown: 1}})
t.Assert(jobID, c.Equals, id)
t.Assert(app.flynn("log", "--raw-output"), Outputs, "hello\nworld\n")
// test stdin and stderr
streams := app.flynnCmd("run", "sh", "-c", "cat 1>&2")
stdin, err := streams.StdinPipe()
t.Assert(err, c.IsNil)
go func() {
stdin.Write([]byte("goto stderr"))
stdin.Close()
}()
var stderr bytes.Buffer
var stdout bytes.Buffer
streams.Stderr = &stderr
streams.Stdout = &stdout
t.Assert(streams.Run(), c.IsNil)
t.Assert(stderr.String(), c.Equals, "goto stderr")
t.Assert(stdout.String(), c.Equals, "")
// test exit code
exit := app.sh("exit 42")
t.Assert(exit, c.Not(Succeeds))
if msg, ok := exit.Err.(*exec.ExitError); ok { // there is error code
code := msg.Sys().(syscall.WaitStatus).ExitStatus()
t.Assert(code, c.Equals, 42)
} else {
t.Fatal("There was no error code!")
}
}
示例7: TestDumpRestore
func (s *RedisSuite) TestDumpRestore(t *c.C) {
a := s.newCliTestApp(t)
res := a.flynn("resource", "add", "redis")
t.Assert(res, Succeeds)
id := strings.Split(res.Output, " ")[2]
release, err := s.controllerClient(t).GetAppRelease(a.id)
t.Assert(err, c.IsNil)
t.Assert(release.Env["FLYNN_REDIS"], c.Not(c.Equals), "")
a.waitForService(release.Env["FLYNN_REDIS"])
t.Assert(a.flynn("redis", "redis-cli", "set", "foo", "bar"), Succeeds)
file := filepath.Join(t.MkDir(), "dump.rdb")
t.Assert(a.flynn("redis", "dump", "-f", file), Succeeds)
t.Assert(a.flynn("redis", "redis-cli", "del", "foo"), Succeeds)
a.flynn("redis", "restore", "-f", file)
query := a.flynn("redis", "redis-cli", "get", "foo")
t.Assert(query, SuccessfulOutputContains, "bar")
t.Assert(a.flynn("resource", "remove", "redis", id), Succeeds)
}
示例8: TestNonMasterPush
func (s *GitDeploySuite) TestNonMasterPush(t *c.C) {
r := s.newGitRepo(t, "empty")
t.Assert(r.flynn("create"), Succeeds)
push := r.git("push", "flynn", "master:foo")
t.Assert(push, c.Not(Succeeds))
t.Assert(push, OutputContains, "push must include a change to the master branch")
}
示例9: TestVolumeCreation
func (s *HostSuite) TestVolumeCreation(t *c.C) {
h := s.anyHostClient(t)
vol, err := h.CreateVolume("default")
t.Assert(err, c.IsNil)
t.Assert(vol.ID, c.Not(c.Equals), "")
t.Assert(h.DestroyVolume(vol.ID), c.IsNil)
}
示例10: TestVolumeDeleteOnStop
func (s *HostSuite) TestVolumeDeleteOnStop(t *c.C) {
hosts, err := s.clusterClient(t).Hosts()
t.Assert(err, c.IsNil)
t.Assert(hosts, c.Not(c.HasLen), 0)
h := hosts[0]
// stream job events so we can wait for cleanup events
events := make(chan *host.Event)
stream, err := h.StreamEvents("all", events)
t.Assert(err, c.IsNil)
defer stream.Close()
waitCleanup := func(jobID string) {
timeout := time.After(30 * time.Second)
for {
select {
case event := <-events:
if event.JobID == jobID && event.Event == host.JobEventCleanup {
return
}
case <-timeout:
t.Fatal("timed out waiting for cleanup event")
}
}
}
for _, deleteOnStop := range []bool{true, false} {
job := &host.Job{
Config: host.ContainerConfig{
Args: []string{"sh", "-c", "ls -d /foo"},
DisableLog: true,
},
}
// provision a volume
req := &ct.VolumeReq{Path: "/foo", DeleteOnStop: deleteOnStop}
vol, err := utils.ProvisionVolume(req, h, job)
t.Assert(err, c.IsNil)
defer h.DestroyVolume(vol.ID)
// run the job
cmd := exec.JobUsingCluster(s.clusterClient(t), s.createArtifact(t, "test-apps"), job)
cmd.HostID = h.ID()
out, err := cmd.CombinedOutput()
t.Assert(err, c.IsNil)
t.Assert(string(out), c.Equals, "/foo\n")
// wait for a cleanup event
waitCleanup(job.ID)
// check if the volume was deleted or not
vol, err = h.GetVolume(vol.ID)
if deleteOnStop {
t.Assert(hh.IsObjectNotFoundError(err), c.Equals, true)
} else {
t.Assert(err, c.IsNil)
}
}
}
示例11: TestScaleAll
func (s *CLISuite) TestScaleAll(t *c.C) {
client := s.controllerClient(t)
app := s.newCliTestApp(t)
release := app.release
defer app.cleanup()
scale := app.flynn("scale", "echoer=1", "printer=2")
t.Assert(scale, Succeeds)
scale = app.flynn("scale", "--all")
t.Assert(scale, Succeeds)
t.Assert(scale, SuccessfulOutputContains, fmt.Sprintf("%s (current)\n", release.ID))
t.Assert(scale, SuccessfulOutputContains, "echoer=1")
t.Assert(scale, SuccessfulOutputContains, "printer=2")
prevRelease := release
release = &ct.Release{
ArtifactIDs: release.ArtifactIDs,
Env: release.Env,
Meta: release.Meta,
Processes: release.Processes,
}
t.Assert(client.CreateRelease(release), c.IsNil)
t.Assert(client.SetAppRelease(app.id, release.ID), c.IsNil)
scale = app.flynn("scale", "echoer=2", "printer=1")
t.Assert(scale, Succeeds)
scale = app.flynn("scale", "--all")
t.Assert(scale, Succeeds)
t.Assert(scale, SuccessfulOutputContains, fmt.Sprintf("%s (current)\n", release.ID))
t.Assert(scale, SuccessfulOutputContains, "echoer=2")
t.Assert(scale, SuccessfulOutputContains, "printer=1")
t.Assert(scale, SuccessfulOutputContains, fmt.Sprintf("%s\n", prevRelease.ID))
t.Assert(scale, SuccessfulOutputContains, "echoer=1")
t.Assert(scale, SuccessfulOutputContains, "printer=2")
scale = app.flynn("scale", "--all", "--release", release.ID)
t.Assert(scale, c.Not(Succeeds))
scale = app.flynn("scale", "--all", "echoer=3", "printer=3")
t.Assert(scale, c.Not(Succeeds))
}
示例12: TestReleaseDelete
func (s *CLISuite) TestReleaseDelete(t *c.C) {
// create an app and release it twice
r := s.newGitRepo(t, "http")
app := "release-delete-" + random.String(8)
t.Assert(r.flynn("create", app), Succeeds)
t.Assert(r.git("push", "flynn", "master"), Succeeds)
t.Assert(r.git("commit", "--allow-empty", "--message", "empty commit"), Succeeds)
t.Assert(r.git("push", "flynn", "master"), Succeeds)
// get the releases
client := s.controllerClient(t)
releases, err := client.AppReleaseList(app)
t.Assert(err, c.IsNil)
t.Assert(releases, c.HasLen, 2)
// check the current release cannot be deleted
res := r.flynn("release", "delete", "--yes", releases[0].ID)
t.Assert(res, c.Not(Succeeds))
t.Assert(res.Output, c.Equals, "validation_error: cannot delete current app release\n")
// associate the initial release with another app
otherApp := &ct.App{Name: "release-delete-" + random.String(8)}
t.Assert(client.CreateApp(otherApp), c.IsNil)
t.Assert(client.PutFormation(&ct.Formation{AppID: otherApp.ID, ReleaseID: releases[1].ID}), c.IsNil)
// check deleting the initial release just deletes the formation
res = r.flynn("release", "delete", "--yes", releases[1].ID)
t.Assert(res, Succeeds)
t.Assert(res.Output, c.Equals, "Release scaled down for app but not fully deleted (still associated with 1 other apps)\n")
// check the slug artifact still exists
slugArtifact, err := client.GetArtifact(releases[1].ArtifactIDs[1])
t.Assert(err, c.IsNil)
s.assertURI(t, slugArtifact.URI, http.StatusOK)
slugLayerURL := slugArtifact.LayerURL(slugArtifact.Manifest().Rootfs[0].Layers[0])
s.assertURI(t, slugLayerURL, http.StatusOK)
// check the inital release can now be deleted
res = r.flynn("-a", otherApp.ID, "release", "delete", "--yes", releases[1].ID)
t.Assert(res, Succeeds)
t.Assert(res.Output, c.Equals, fmt.Sprintf("Deleted release %s (deleted 2 files)\n", releases[1].ID))
// check the slug artifact was deleted
_, err = client.GetArtifact(slugArtifact.ID)
t.Assert(err, c.Equals, controller.ErrNotFound)
s.assertURI(t, slugArtifact.URI, http.StatusNotFound)
s.assertURI(t, slugLayerURL, http.StatusNotFound)
// check the image artifact was not deleted (since it is shared between both releases)
_, err = client.GetArtifact(releases[1].ArtifactIDs[0])
t.Assert(err, c.IsNil)
}
示例13: TestResourceRemove
func (s *CLISuite) TestResourceRemove(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
add := app.flynn("resource", "add", "postgres")
t.Assert(add, Succeeds)
t.Assert(app.flynn("resource").Output, Matches, "postgres")
t.Assert(app.flynn("env").Output, Matches, "FLYNN_POSTGRES")
id := strings.Split(add.Output, " ")[2]
// change one of the env vars provided by the resource
t.Assert(app.flynn("env", "set", "PGUSER=testuser"), Succeeds)
remove := app.flynn("resource", "remove", "postgres", id)
t.Assert(remove, Succeeds)
t.Assert(app.flynn("resource").Output, c.Not(Matches), "postgres")
// test that unmodified vars are removed
t.Assert(app.flynn("env").Output, c.Not(Matches), "FLYNN_POSTGRES")
// but that modifed ones are retained
t.Assert(app.flynn("env", "get", "PGUSER").Output, Matches, "testuser")
}
示例14: TestAddFailingJob
func (s *HostSuite) TestAddFailingJob(t *c.C) {
// get a host and watch events
hosts, err := s.clusterClient(t).Hosts()
t.Assert(err, c.IsNil)
t.Assert(hosts, c.Not(c.HasLen), 0)
h := hosts[0]
jobID := random.UUID()
events := make(chan *host.Event)
stream, err := h.StreamEvents(jobID, events)
t.Assert(err, c.IsNil)
defer stream.Close()
// add a job with a non existent partition
job := &host.Job{
ID: jobID,
ImageArtifact: &host.Artifact{
Type: host.ArtifactTypeDocker,
URI: "http://example.com?name=foo&id=bar",
},
Partition: "nonexistent",
}
t.Assert(h.AddJob(job), c.IsNil)
// check we get a create then error event
actual := make(map[string]*host.Event, 2)
loop:
for {
select {
case e, ok := <-events:
if !ok {
t.Fatalf("job event stream closed unexpectedly: %s", stream.Err())
}
if _, ok := actual[e.Event]; ok {
t.Fatalf("unexpected event: %v", e)
}
actual[e.Event] = e
if len(actual) >= 2 {
break loop
}
case <-time.After(30 * time.Second):
t.Fatal("timed out waiting for job event")
}
}
t.Assert(actual[host.JobEventCreate], c.NotNil)
e := actual[host.JobEventError]
t.Assert(e, c.NotNil)
t.Assert(e.Job, c.NotNil)
t.Assert(e.Job.Error, c.NotNil)
t.Assert(*e.Job.Error, c.Equals, `host: invalid job partition "nonexistent"`)
}
示例15: TestRunNoImage
func (s *CLISuite) TestRunNoImage(t *c.C) {
r := s.newGitRepo(t, "empty-release")
t.Assert(r.flynn("create"), Succeeds)
t.Assert(r.flynn("env", "set", "FOO=BAR", "BUILDPACK_URL=https://github.com/kr/heroku-buildpack-inline"), Succeeds)
// running a command before pushing should error
cmd := r.flynn("run", "env")
t.Assert(cmd, c.Not(Succeeds))
t.Assert(cmd, OutputContains, "App release has no image, push a release first")
// command should work after push
t.Assert(r.git("push", "flynn", "master"), Succeeds)
cmd = r.flynn("run", "env")
t.Assert(cmd, Succeeds)
t.Assert(cmd, OutputContains, "FOO=BAR")
}