当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.StartGandalfTestServer函数代码示例

本文整理汇总了Golang中github.com/tsuru/tsuru/testing.StartGandalfTestServer函数的典型用法代码示例。如果您正苦于以下问题:Golang StartGandalfTestServer函数的具体用法?Golang StartGandalfTestServer怎么用?Golang StartGandalfTestServer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StartGandalfTestServer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的github.com/tsuru/tsuru/testing.StartGandalfTestServer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。