本文整理汇总了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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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!")
}
示例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{})
}
示例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")
}
示例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")
}
示例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{})
}
示例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)
}
示例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
}
示例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)
}
示例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)
}
示例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()
}