本文整理汇总了Golang中github.com/tsuru/tsuru/testing.StartGandalfTestServer函数的典型用法代码示例。如果您正苦于以下问题:Golang StartGandalfTestServer函数的具体用法?Golang StartGandalfTestServer怎么用?Golang StartGandalfTestServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartGandalfTestServer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestDeployLogsActions
func (s *S) TestDeployLogsActions(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
provisioner := testing.NewFakeProvisioner()
provisioner.PrepareOutput([]byte(""))
provisioner.PrepareOutput([]byte("updated"))
app := testing.NewFakeApp("cribcaged", "python", 1)
provisioner.Provision(app)
w := &bytes.Buffer{}
err := Git(provisioner, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7", w)
c.Assert(err, gocheck.IsNil)
logs := w.String()
expected := `
---> tsuru receiving push
---> Replicating the application repository across units
---> Installing dependencies
---> Restarting application
Restarting app...
---> Deploy done!
`
c.Assert(logs, gocheck.Equals, expected)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:27,代码来源:git_test.go
示例2: TestDestroyWithELB
func (s *ELBSuite) TestDestroyWithELB(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
config.Set("juju:charms-path", "/home/charms")
defer config.Unset("juju:charms-path")
fexec := &etesting.FakeExecutor{}
setExecut(fexec)
defer setExecut(nil)
app := testing.NewFakeApp("jimmy", "who", 0)
p := JujuProvisioner{}
err := p.Provision(app)
c.Assert(err, gocheck.IsNil)
err = p.Destroy(app)
c.Assert(err, gocheck.IsNil)
router, err := Router()
c.Assert(err, gocheck.IsNil)
defer router.RemoveBackend(app.GetName())
addr, err := router.Addr(app.GetName())
c.Assert(addr, gocheck.Equals, "")
c.Assert(err, gocheck.NotNil)
c.Assert(err, gocheck.ErrorMatches, "not found")
q := getQueue(queueName)
msg, err := q.Get(1e9)
c.Assert(err, gocheck.IsNil)
if msg.Action != addUnitToLoadBalancer {
q.Put(msg, 0)
}
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:29,代码来源:provisioner_test.go
示例3: TestDestroyShouldUnbindAppFromInstance
func (s *S) TestDestroyShouldUnbindAppFromInstance(c *gocheck.C) {
h := testHandler{}
tsg := testing.StartGandalfTestServer(&h)
defer tsg.Close()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
}))
defer ts.Close()
srvc := service.Service{Name: "my", Endpoint: map[string]string{"production": ts.URL}}
err := srvc.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.Services().Remove(bson.M{"_id": srvc.Name})
instance := service.ServiceInstance{Name: "MyInstance", Apps: []string{"whichapp"}, ServiceName: srvc.Name}
err = instance.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.ServiceInstances().Remove(bson.M{"_id": instance.Name})
a := App{
Name: "whichapp",
Platform: "python",
Teams: []string{},
}
err = CreateApp(&a, s.user)
c.Assert(err, gocheck.IsNil)
app, err := GetByName(a.Name)
c.Assert(err, gocheck.IsNil)
err = Delete(app)
c.Assert(err, gocheck.IsNil)
n, err := s.conn.ServiceInstances().Find(bson.M{"apps": bson.M{"$in": []string{a.Name}}}).Count()
c.Assert(err, gocheck.IsNil)
c.Assert(n, gocheck.Equals, 0)
}
开发者ID:rualatngua,项目名称:tsuru,代码行数:31,代码来源:bind_test.go
示例4: SetUpTest
func (s *S) SetUpTest(c *gocheck.C) {
s.conn, _ = db.Conn()
s.reqs = make([]*http.Request, 0)
s.bodies = make([]string, 0)
s.rsps = make(map[string]string)
s.testHandler = tsuruTesting.TestHandler{}
s.gandalf = tsuruTesting.StartGandalfTestServer(&s.testHandler)
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:8,代码来源:suite_test.go
示例5: SetUpSuite
func (s *S) SetUpSuite(c *gocheck.C) {
config.Set("git:api-server", "http://mygihost:8090")
config.Set("git:rw-host", "public.mygithost")
config.Set("git:ro-host", "private.mygithost")
config.Set("git:unit-repo", "/home/application/current")
content := `{"git_url":"git://git.tsuru.io/foobar.git","ssh_url":"[email protected]:foobar.git"}`
s.h = &tsrTesting.TestHandler{Content: content}
s.ts = tsrTesting.StartGandalfTestServer(s.h)
}
开发者ID:rualatngua,项目名称:tsuru,代码行数:9,代码来源:suite_test.go
示例6: TestDeployRemoveContainersEvenWhenTheyreNotInTheAppsCollection
func (s *S) TestDeployRemoveContainersEvenWhenTheyreNotInTheAppsCollection(c *gocheck.C) {
h := &tsrTesting.TestHandler{}
gandalfServer := tsrTesting.StartGandalfTestServer(h)
defer gandalfServer.Close()
go s.stopContainers(3)
err := newImage("tsuru/python", s.server.URL())
c.Assert(err, gocheck.IsNil)
cont1, err := s.newContainer(nil)
defer s.removeTestContainer(cont1)
c.Assert(err, gocheck.IsNil)
cont2, err := s.newContainer(nil)
defer s.removeTestContainer(cont2)
c.Assert(err, gocheck.IsNil)
defer rtesting.FakeRouter.RemoveBackend(cont1.AppName)
var p dockerProvisioner
a := app.App{
Name: "otherapp",
Platform: "python",
Units: []app.Unit{{Name: "i-0800", State: "started"}},
}
conn, err := db.Conn()
defer conn.Close()
err = conn.Apps().Insert(a)
c.Assert(err, gocheck.IsNil)
defer conn.Apps().Remove(bson.M{"name": a.Name})
p.Provision(&a)
defer p.Destroy(&a)
fexec := &etesting.FakeExecutor{}
setExecut(fexec)
defer setExecut(nil)
var w bytes.Buffer
err = app.Deploy(app.DeployOptions{
App: &a,
Version: "master",
Commit: "123",
OutputStream: &w,
})
c.Assert(err, gocheck.IsNil)
time.Sleep(1e9)
defer p.Destroy(&a)
q, err := getQueue()
c.Assert(err, gocheck.IsNil)
for _, u := range a.ProvisionedUnits() {
message, err := q.Get(1e6)
c.Assert(err, gocheck.IsNil)
c.Assert(message.Action, gocheck.Equals, app.BindService)
c.Assert(message.Args[0], gocheck.Equals, a.GetName())
c.Assert(message.Args[1], gocheck.Equals, u.GetName())
}
coll := collection()
defer coll.Close()
n, err := coll.Find(bson.M{"appname": cont1.AppName}).Count()
c.Assert(err, gocheck.IsNil)
c.Assert(n, gocheck.Equals, 2)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:56,代码来源:provisioner_test.go
示例7: TestAddrWithoutUnits
func (s *S) TestAddrWithoutUnits(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
app := testing.NewFakeApp("squeeze", "who", 0)
p := JujuProvisioner{}
addr, err := p.Addr(app)
c.Assert(addr, gocheck.Equals, "")
c.Assert(err, gocheck.NotNil)
c.Assert(err.Error(), gocheck.Equals, `App "squeeze" has no units.`)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:11,代码来源:provisioner_test.go
示例8: TestCreateRepositoryBackward
func (s *S) TestCreateRepositoryBackward(c *gocheck.C) {
h := testHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
app := App{Name: "someapp"}
ctx := action.BWContext{FWResult: &app, Params: []interface{}{app}}
createRepository.Backward(ctx)
c.Assert(h.url[0], gocheck.Equals, "/repository/someapp")
c.Assert(h.method[0], gocheck.Equals, "DELETE")
c.Assert(string(h.body[0]), gocheck.Equals, "null")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:11,代码来源:actions_test.go
示例9: TestListKeysGandalfAPIError
func (s *S) TestListKeysGandalfAPIError(c *gocheck.C) {
h := testBadHandler{content: "some terrible error"}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
u := User{Email: "[email protected]", Password: "123456"}
err := u.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.Users().Remove(bson.M{"email": u.Email})
keys, err := u.ListKeys()
c.Assert(keys, gocheck.DeepEquals, map[string]string(nil))
c.Assert(err.Error(), gocheck.Equals, "some terrible error\n")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:12,代码来源:user_test.go
示例10: TestGetDiffInDeploysWithOneCommit
func (s *S) TestGetDiffInDeploysWithOneCommit(c *gocheck.C) {
s.conn.Deploys().RemoveAll(nil)
lastDeploy := deploy{App: "g1", Timestamp: time.Now(), Commit: "1b970b076bbb30d708e262b402d4e31910e1dc10"}
s.conn.Deploys().Insert(lastDeploy)
defer s.conn.Deploys().RemoveAll(nil)
expected := "test_diff"
h := testHandler{content: expected}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
_, err := GetDiffInDeploys(&lastDeploy)
c.Assert(err.Error(), gocheck.Equals, "The deployment must have at least two commits for the diff.")
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:12,代码来源:deploy_test.go
示例11: TestCreateUserOnGandalf
func (s *S) TestCreateUserOnGandalf(c *gocheck.C) {
h := testing.TestHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
u := &User{Email: "[email protected]"}
err := u.CreateOnGandalf()
c.Assert(err, gocheck.IsNil)
c.Assert(h.Url, gocheck.Equals, "/user")
expected := `{"name":"[email protected]","keys":{}}`
c.Assert(string(h.Body), gocheck.Equals, expected)
c.Assert(h.Method, gocheck.Equals, "POST")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:12,代码来源:user_test.go
示例12: TestContainerDeploy
func (s *S) TestContainerDeploy(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
err := newImage("tsuru/python", s.server.URL())
c.Assert(err, gocheck.IsNil)
app := testing.NewFakeApp("myapp", "python", 1)
rtesting.FakeRouter.AddBackend(app.GetName())
defer rtesting.FakeRouter.RemoveBackend(app.GetName())
var buf bytes.Buffer
_, err = deploy(app, "ff13e", &buf)
c.Assert(err, gocheck.IsNil)
}
开发者ID:kennylixi,项目名称:tsuru,代码行数:13,代码来源:docker_test.go
示例13: TestAddKeyInGandalfShouldCallGandalfAPI
func (s *S) TestAddKeyInGandalfShouldCallGandalfAPI(c *gocheck.C) {
h := testing.TestHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
u := &User{Email: "[email protected]"}
err := u.Create()
c.Assert(err, gocheck.IsNil)
defer u.Delete()
key := Key{Content: "my-ssh-key", Name: "key1"}
err = u.AddKeyGandalf(&key)
c.Assert(err, gocheck.IsNil)
c.Assert(h.Url, gocheck.Equals, "/user/[email protected]/key")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:13,代码来源:user_test.go
示例14: TestAddKeyInGandalfActionBackward
func (s *ActionsSuite) TestAddKeyInGandalfActionBackward(c *gocheck.C) {
h := testHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
key := &auth.Key{Name: "mysshkey", Content: "my-ssh-key"}
u := &auth.User{Email: "[email protected]", Password: "123456"}
ctx := action.BWContext{
Params: []interface{}{key, u},
}
addKeyInGandalfAction.Backward(ctx)
c.Assert(len(h.url), gocheck.Equals, 1)
expected := fmt.Sprintf("/user/%s/key/%s", u.Email, key.Name)
c.Assert(h.url[0], gocheck.Equals, expected)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:14,代码来源:actions_test.go
示例15: TestCloneRepository
func (s *S) TestCloneRepository(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
p := testing.NewFakeProvisioner()
p.PrepareOutput([]byte("something"))
app := testing.NewFakeApp("your", "python", 1)
out, err := clone(p, app)
c.Assert(err, gocheck.IsNil)
c.Assert(string(out), gocheck.Equals, "something")
url := repository.ReadOnlyURL(app.GetName())
path, _ := repository.GetPath()
expectedCommand := fmt.Sprintf("git clone %s %s --depth 1", url, path)
c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:15,代码来源:git_test.go
示例16: TestListKeysShouldCallGandalfAPI
func (s *S) TestListKeysShouldCallGandalfAPI(c *gocheck.C) {
h := testHandler{content: `{"mypckey":"ssh-rsa keystuff keycomment"}`}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
u := User{Email: "[email protected]", Password: "123456"}
err := u.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.Users().Remove(bson.M{"email": u.Email})
keys, err := u.ListKeys()
c.Assert(err, gocheck.IsNil)
expected := map[string]string{"mypckey": "ssh-rsa keystuff keycomment"}
c.Assert(expected, gocheck.DeepEquals, keys)
c.Assert(h.url[0], gocheck.Equals, "/user/[email protected]/keys")
c.Assert(h.method[0], gocheck.Equals, "GET")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:15,代码来源:user_test.go
示例17: TestRestartFailure
func (s *S) TestRestartFailure(c *gocheck.C) {
h := &testing.TestHandler{}
gandalfServer := testing.StartGandalfTestServer(h)
defer gandalfServer.Close()
tmpdir, err := commandmocker.Error("juju", "juju failed to run command", 25)
c.Assert(err, gocheck.IsNil)
defer commandmocker.Remove(tmpdir)
app := testing.NewFakeApp("cribcaged", "python", 1)
p := JujuProvisioner{}
err = p.Restart(app)
c.Assert(err, gocheck.NotNil)
pErr, ok := err.(*provision.Error)
c.Assert(ok, gocheck.Equals, true)
c.Assert(pErr.Reason, gocheck.Equals, "juju failed to run command\n")
c.Assert(pErr.Err.Error(), gocheck.Equals, "exit status 25")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:16,代码来源:provisioner_test.go
示例18: TestAddKeyInGandalfActionForward
func (s *ActionsSuite) TestAddKeyInGandalfActionForward(c *gocheck.C) {
h := testHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
key := &auth.Key{Name: "mysshkey", Content: "my-ssh-key"}
u := &auth.User{Email: "[email protected]", Password: "123456"}
ctx := action.FWContext{
Params: []interface{}{key, u},
}
result, err := addKeyInGandalfAction.Forward(ctx)
c.Assert(err, gocheck.IsNil)
c.Assert(result, gocheck.IsNil) // we're not gonna need the result
c.Assert(len(h.url), gocheck.Equals, 1)
expected := fmt.Sprintf("/user/%s/key", u.Email)
c.Assert(h.url[0], gocheck.Equals, expected)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:16,代码来源:actions_test.go
示例19: TestAddUserToTeamInGandalfActionBackward
func (s *ActionsSuite) TestAddUserToTeamInGandalfActionBackward(c *gocheck.C) {
h := testHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
u := &auth.User{Email: "[email protected]", Password: "123456"}
err := u.Create()
c.Assert(err, gocheck.IsNil)
defer s.conn.Users().Remove(bson.M{"email": u.Email})
t := &auth.Team{Name: "myteam"}
ctx := action.BWContext{
Params: []interface{}{u, t},
}
addUserToTeamInGandalfAction.Backward(ctx)
c.Assert(len(h.url), gocheck.Equals, 1)
c.Assert(h.url[0], gocheck.Equals, "/repository/revoke")
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:16,代码来源:actions_test.go
示例20: TestCreateRepositoryForwardAppPointer
func (s *S) TestCreateRepositoryForwardAppPointer(c *gocheck.C) {
h := testHandler{}
ts := testing.StartGandalfTestServer(&h)
defer ts.Close()
app := App{Name: "someapp", Teams: []string{s.team.Name}}
ctx := action.FWContext{Params: []interface{}{&app}}
result, err := createRepository.Forward(ctx)
a, ok := result.(*App)
c.Assert(ok, gocheck.Equals, true)
c.Assert(a.Name, gocheck.Equals, app.Name)
c.Assert(err, gocheck.IsNil)
c.Assert(h.url[0], gocheck.Equals, "/repository")
c.Assert(h.method[0], gocheck.Equals, "POST")
expected := fmt.Sprintf(`{"name":"someapp","users":["%s"],"ispublic":false}`, s.user.Email)
c.Assert(string(h.body[0]), gocheck.Equals, expected)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:16,代码来源:actions_test.go
注:本文中的github.com/tsuru/tsuru/testing.StartGandalfTestServer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论