當前位置: 首頁>>代碼示例>>Golang>>正文


Golang testing.NewFakeProvisioner函數代碼示例

本文整理匯總了Golang中github.com/tsuru/tsuru/testing.NewFakeProvisioner函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewFakeProvisioner函數的具體用法?Golang NewFakeProvisioner怎麽用?Golang NewFakeProvisioner使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewFakeProvisioner函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestDeployAppSaveDeployErrorData

func (s *S) TestDeployAppSaveDeployErrorData(c *gocheck.C) {
	provisioner := testing.PipelineErrorFakeProvisioner{
		FakeProvisioner: testing.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	a := App{
		Name:     "testErrorApp",
		Platform: "zend",
		Teams:    []string{s.team.Name},
	}
	err := s.conn.Apps().Insert(a)
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Apps().Remove(bson.M{"name": a.Name})
	provisioner.Provision(&a)
	defer provisioner.Destroy(&a)
	writer := &bytes.Buffer{}
	err = Deploy(DeployOptions{
		App:          &a,
		Version:      "version",
		Commit:       "1ee1f1084927b3a5db59c9033bc5c4abefb7b93c",
		OutputStream: writer,
	})
	c.Assert(err, gocheck.NotNil)
	var result map[string]interface{}
	s.conn.Deploys().Find(bson.M{"app": a.Name}).One(&result)
	c.Assert(result["app"], gocheck.Equals, a.Name)
	c.Assert(result["error"], gocheck.NotNil)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:31,代碼來源:deploy_test.go

示例2: TestPlatformWithAppsCantBeRemoved

func (s *PlatformSuite) TestPlatformWithAppsCantBeRemoved(c *gocheck.C) {
	provisioner := testing.ExtensibleFakeProvisioner{
		FakeProvisioner: testing.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, gocheck.IsNil)
	defer conn.Close()
	name := "test_platform_update"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(name, nil, nil)
	c.Assert(err, gocheck.IsNil)
	defer conn.Platforms().Remove(bson.M{"_id": name})
	appName := "test_another_app"
	app := App{
		Name:     appName,
		Platform: name,
	}
	err = conn.Apps().Insert(app)
	c.Assert(err, gocheck.IsNil)
	defer conn.Apps().Remove(bson.M{"_id": appName})
	err = PlatformRemove(name)
	c.Assert(err, gocheck.NotNil)
}
開發者ID:rualatngua,項目名稱:tsuru,代碼行數:28,代碼來源:platform_test.go

示例3: 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

示例4: TestPlatformUpdateShouldSetUpdatePlatformFlagOnApps

func (s *PlatformSuite) TestPlatformUpdateShouldSetUpdatePlatformFlagOnApps(c *gocheck.C) {
	provisioner := testing.ExtensibleFakeProvisioner{
		FakeProvisioner: testing.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, gocheck.IsNil)
	defer conn.Close()
	name := "test_platform_update"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(name, nil, nil)
	c.Assert(err, gocheck.IsNil)
	defer conn.Platforms().Remove(bson.M{"_id": name})
	appName := "test_app"
	app := App{
		Name:     appName,
		Platform: name,
	}
	err = conn.Apps().Insert(app)
	c.Assert(err, gocheck.IsNil)
	defer conn.Apps().Remove(bson.M{"_id": appName})
	err = PlatformUpdate(name, args, nil)
	c.Assert(err, gocheck.IsNil)
	a, err := GetByName(appName)
	c.Assert(err, gocheck.IsNil)
	c.Assert(a.UpdatePlatform, gocheck.Equals, true)
}
開發者ID:ningjh,項目名稱:tsuru,代碼行數:31,代碼來源:platform_test.go

示例5: TestDeployCustomPipeline

func (s *S) TestDeployCustomPipeline(c *gocheck.C) {
	provisioner := testing.PipelineFakeProvisioner{
		FakeProvisioner: testing.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	a := App{
		Name:     "otherapp",
		Platform: "zend",
		Teams:    []string{s.team.Name},
	}
	err := s.conn.Apps().Insert(a)
	c.Assert(err, gocheck.IsNil)
	defer s.conn.Apps().Remove(bson.M{"name": a.Name})
	provisioner.Provision(&a)
	defer provisioner.Destroy(&a)
	writer := &bytes.Buffer{}
	err = Deploy(DeployOptions{
		App:          &a,
		Version:      "version",
		Commit:       "1ee1f1084927b3a5db59c9033bc5c4abefb7b93c",
		OutputStream: writer,
	})
	c.Assert(err, gocheck.IsNil)
	c.Assert(provisioner.ExecutedPipeline(), gocheck.Equals, true)
}
開發者ID:WIZARD-CXY,項目名稱:golang-devops-stuff,代碼行數:28,代碼來源:deploy_test.go

示例6: TestPlatformRemove

func (s *PlatformSuite) TestPlatformRemove(c *gocheck.C) {
	provisioner := testing.ExtensibleFakeProvisioner{
		FakeProvisioner: testing.NewFakeProvisioner(),
	}
	Provisioner = &provisioner
	defer func() {
		Provisioner = s.provisioner
	}()
	conn, err := db.Conn()
	c.Assert(err, gocheck.IsNil)
	defer conn.Close()
	err = PlatformRemove("platform_dont_exists")
	c.Assert(err, gocheck.NotNil)
	name := "test_platform_update"
	args := make(map[string]string)
	args["dockerfile"] = "http://localhost/Dockerfile"
	err = PlatformAdd(name, nil, nil)
	c.Assert(err, gocheck.IsNil)
	defer conn.Platforms().Remove(bson.M{"_id": name})
	err = PlatformRemove(name)
	c.Assert(err, gocheck.IsNil)
	err = PlatformRemove("")
	c.Assert(err, gocheck.NotNil)
	c.Assert(err.Error(), gocheck.Equals, "Platform name is required!")
}
開發者ID:rualatngua,項目名稱:tsuru,代碼行數:25,代碼來源:platform_test.go

示例7: TestShouldRegisterAllCommandsFromProvisioners

func (s *S) TestShouldRegisterAllCommandsFromProvisioners(c *gocheck.C) {
	fp := testing.NewFakeProvisioner()
	p := AdminCommandableProvisioner{FakeProvisioner: *fp}
	provision.Register("fakeAdminProvisioner", &p)
	manager := buildManager("tsuru-admin")
	fake, ok := manager.Commands["fake-admin"]
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(fake, gocheck.FitsTypeOf, &FakeAdminCommand{})
}
開發者ID:ningjh,項目名稱:tsuru,代碼行數:9,代碼來源:main_test.go

示例8: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_collector_test")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.provisioner = ttesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
	config.Set("queue-server", "127.0.0.1:0")
}
開發者ID:ningjh,項目名稱:tsuru,代碼行數:10,代碼來源:suite_test.go

示例9: TestCheckoutFailure

func (s *S) TestCheckoutFailure(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("failed to update"))
	p.PrepareFailure("ExecuteCommand", errors.New("exit status 128"))
	app := testing.NewFakeApp("moon", "python", 1)
	out, err := checkout(p, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7")
	c.Assert(err, gocheck.NotNil)
	c.Assert(err.Error(), gocheck.Equals, "exit status 128")
	c.Assert(string(out), gocheck.Equals, "failed to update")
}
開發者ID:rochacon,項目名稱:tsuru,代碼行數:10,代碼來源:git_test.go

示例10: TestShouldRegisterAllCommandsFromProvisioners

func (s *S) TestShouldRegisterAllCommandsFromProvisioners(c *gocheck.C) {
	fp := testing.NewFakeProvisioner()
	p := CommandableProvisioner{FakeProvisioner: *fp}
	provision.Register("comm", &p)
	manager := buildManager()
	fake, ok := manager.Commands["fake"]
	c.Assert(ok, gocheck.Equals, true)
	tsrFake, ok := fake.(*tsrCommand)
	c.Assert(ok, gocheck.Equals, true)
	c.Assert(tsrFake.Command, gocheck.FitsTypeOf, &FakeCommand{})
}
開發者ID:tomzhang,項目名稱:golang-devops-stuff,代碼行數:11,代碼來源:main_test.go

示例11: TestPullRepository

func (s *S) TestPullRepository(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("pulled"))
	app := testing.NewFakeApp("your", "python", 1)
	out, err := fetch(p, app)
	c.Assert(err, gocheck.IsNil)
	c.Assert(string(out), gocheck.Equals, "pulled")
	path, _ := repository.GetPath()
	expectedCommand := fmt.Sprintf("cd %s && git fetch origin", path)
	c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
開發者ID:rochacon,項目名稱:tsuru,代碼行數:11,代碼來源:git_test.go

示例12: SetUpSuite

func (s *DeploySuite) SetUpSuite(c *gocheck.C) {
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_deploy_api_tests")
	config.Set("aut:hash-cost", 4)
	var err error
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.createUserAndTeam(c)
	s.provisioner = testing.NewFakeProvisioner()
	app.Provisioner = s.provisioner
}
開發者ID:rualatngua,項目名稱:tsuru,代碼行數:11,代碼來源:deploy_test.go

示例13: TestCheckout

func (s *S) TestCheckout(c *gocheck.C) {
	p := testing.NewFakeProvisioner()
	p.PrepareOutput([]byte("updated"))
	app := testing.NewFakeApp("moon", "python", 1)
	out, err := checkout(p, app, "5734f0042844fdeb5bbc1b72b18f2dc1779cade7")
	c.Assert(err, gocheck.IsNil)
	c.Assert(out, gocheck.IsNil)
	path, _ := repository.GetPath()
	expectedCommand := fmt.Sprintf("cd %s && git checkout 5734f0042844fdeb5bbc1b72b18f2dc1779cade7", path)
	c.Assert(p.GetCmds(expectedCommand, app), gocheck.HasLen, 1)
}
開發者ID:rochacon,項目名稱:tsuru,代碼行數:11,代碼來源:git_test.go

示例14: SetUpSuite

func (s *S) SetUpSuite(c *gocheck.C) {
	err := config.ReadConfigFile("testdata/config.yaml")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.createUserAndTeam(c)
	s.t = &tsuruTesting.T{}
	s.provisioner = tsuruTesting.NewFakeProvisioner()
	app.Provisioner = s.provisioner
	p := app.Platform{Name: "zend"}
	s.conn.Platforms().Insert(p)
}
開發者ID:royalwang,項目名稱:tsuru,代碼行數:11,代碼來源:suite_test.go

示例15: SetUpSuite

func (s *BindSuite) SetUpSuite(c *gocheck.C) {
	var err error
	config.Set("database:url", "127.0.0.1:27017")
	config.Set("database:name", "tsuru_service_bind_test")
	s.conn, err = db.Conn()
	c.Assert(err, gocheck.IsNil)
	s.user = auth.User{Email: "[email protected]"}
	s.user.Create()
	s.team = auth.Team{Name: "metallica", Users: []string{s.user.Email}}
	s.conn.Teams().Insert(s.team)
	app.Provisioner = ttesting.NewFakeProvisioner()
}
開發者ID:rualatngua,項目名稱:tsuru,代碼行數:12,代碼來源:bind_test.go


注:本文中的github.com/tsuru/tsuru/testing.NewFakeProvisioner函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。