本文整理汇总了Golang中github.com/tsuru/tsuru/testing.NewFakeProvisioner函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFakeProvisioner函数的具体用法?Golang NewFakeProvisioner怎么用?Golang NewFakeProvisioner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFakeProvisioner函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestPlatformUpdateWithoutName
func (s *PlatformSuite) TestPlatformUpdateWithoutName(c *gocheck.C) {
provisioner := testing.ExtensibleFakeProvisioner{
FakeProvisioner: testing.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
err := PlatformUpdate("", nil, nil)
c.Assert(err, gocheck.NotNil)
c.Assert(err.Error(), gocheck.Equals, "Platform name is required.")
}
开发者ID:ningjh,项目名称:tsuru,代码行数:12,代码来源:platform_test.go
示例17: SetUpSuite
func (s *S) SetUpSuite(c *gocheck.C) {
err := config.ReadConfigFile("testdata/config.yaml")
c.Assert(err, gocheck.IsNil)
s.conn, err = db.Conn()
c.Assert(err, gocheck.IsNil)
s.t = &ttesting.T{}
s.createUserAndTeam(c)
s.t.SetGitConfs(c)
s.provisioner = ttesting.NewFakeProvisioner()
Provisioner = s.provisioner
platform := Platform{Name: "python"}
s.conn.Platforms().Insert(platform)
}
开发者ID:renanoliveira,项目名称:tsuru,代码行数:13,代码来源:suite_test.go
示例18: 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
示例19: BenchmarkUpdate
func BenchmarkUpdate(b *testing.B) {
b.StopTimer()
config.Set("database:url", "127.0.0.1:27017")
config.Set("database:name", "collector-benchmark")
conn, err := db.Conn()
if err != nil {
panic(err)
}
defer conn.Apps().Database.DropDatabase()
_, names := getFakeApps(conn)
app.Provisioner = ttesting.NewFakeProvisioner()
fakeUnits := getFakeUnits(names)
b.StartTimer()
for i := 0; i < b.N; i++ {
update(fakeUnits)
}
}
开发者ID:rochacon,项目名称:tsuru,代码行数:17,代码来源:bench_test.go
示例20: TestPlatformAdd
func (p *PlatformSuite) TestPlatformAdd(c *gocheck.C) {
provisioner := testing.ExtensibleFakeProvisioner{
FakeProvisioner: testing.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
dockerfile_url := "http://localhost/Dockerfile"
body := fmt.Sprintf("name=%s&dockerfile=%s", "teste", dockerfile_url)
request, _ := http.NewRequest("POST", "/platforms/add", strings.NewReader(body))
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
recorder := httptest.NewRecorder()
result := platformAdd(recorder, request, nil)
c.Assert(result, gocheck.IsNil)
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:17,代码来源:platform_test.go
注:本文中的github.com/tsuru/tsuru/testing.NewFakeProvisioner函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论