本文整理汇总了Golang中github.com/tsuru/tsuru/provision/provisiontest.NewFakeProvisioner函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFakeProvisioner函数的具体用法?Golang NewFakeProvisioner怎么用?Golang NewFakeProvisioner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFakeProvisioner函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestPlatformUpdateDisabletrueFileIn
func (s *PlatformSuite) TestPlatformUpdateDisabletrueFileIn(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
name := "test_platform_update"
args := make(map[string]string)
args["disabled"] = "true"
err = PlatformAdd(provision.PlatformOptions{Name: name})
c.Assert(err, check.IsNil)
defer conn.Platforms().Remove(bson.M{"_id": name})
appName := "test_app_2"
app := App{
Name: appName,
Platform: name,
}
err = conn.Apps().Insert(app)
c.Assert(err, check.IsNil)
defer conn.Apps().Remove(bson.M{"name": appName})
err = PlatformUpdate(provision.PlatformOptions{Name: name, Args: args, Input: bytes.NewReader(nil)})
c.Assert(err, check.IsNil)
platf, err := GetPlatform(name)
c.Assert(err, check.IsNil)
c.Assert(platf.Disabled, check.Equals, true)
a, err := GetByName(appName)
c.Assert(err, check.IsNil)
c.Assert(a.UpdatePlatform, check.Equals, true)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:34,代码来源:platform_test.go
示例2: TestDeployAppSaveDeployErrorData
func (s *S) TestDeployAppSaveDeployErrorData(c *check.C) {
provisioner := provisiontest.NewFakeProvisioner()
provisioner.PrepareFailure("GitDeploy", errors.New("deploy error"))
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, check.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, check.NotNil)
var result map[string]interface{}
s.conn.Deploys().Find(bson.M{"app": a.Name}).One(&result)
c.Assert(result["app"], check.Equals, a.Name)
c.Assert(result["error"], check.NotNil)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:30,代码来源:deploy_test.go
示例3: TestPlatformUpdate
func (p *PlatformSuite) TestPlatformUpdate(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
err := app.PlatformAdd(provision.PlatformOptions{Name: "wat", Args: nil, Output: nil})
c.Assert(err, check.IsNil)
var buf bytes.Buffer
dockerfileURL := "http://localhost/Dockerfile"
writer := multipart.NewWriter(&buf)
writer.WriteField("dockerfile", dockerfileURL)
writer.Close()
request, _ := http.NewRequest("PUT", "/platforms/wat?:name=wat", &buf)
request.Header.Add("Content-Type", writer.FormDataContentType())
recorder := httptest.NewRecorder()
token := createToken(c)
result := platformUpdate(recorder, request, token)
c.Assert(result, check.IsNil)
b, err := ioutil.ReadAll(recorder.Body)
c.Assert(err, check.IsNil)
var msg io.SimpleJsonMessage
json.Unmarshal(b, &msg)
c.Assert(errors.New(msg.Error), check.ErrorMatches, "")
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:28,代码来源:platform_test.go
示例4: TestPlatformUpdateDisableFalseWithoutDockerfile
func (s *PlatformSuite) TestPlatformUpdateDisableFalseWithoutDockerfile(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
name := "test_platform_update"
args := make(map[string]string)
args["dockerfile"] = ""
args["disabled"] = "false"
err = PlatformAdd(provision.PlatformOptions{Name: name})
c.Assert(err, check.IsNil)
defer conn.Platforms().Remove(bson.M{"_id": name})
appName := "test_app_4"
app := App{
Name: appName,
Platform: name,
}
err = conn.Apps().Insert(app)
c.Assert(err, check.IsNil)
defer conn.Apps().Remove(bson.M{"_id": appName})
err = PlatformUpdate(provision.PlatformOptions{Name: name, Args: args})
c.Assert(err, check.IsNil)
platf, err := GetPlatform(name)
c.Assert(err, check.IsNil)
c.Assert(platf.Disabled, check.Equals, false)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:32,代码来源:platform_test.go
示例5: TestPlatformUpdateShouldSetUpdatePlatformFlagOnApps
func (s *PlatformSuite) TestPlatformUpdateShouldSetUpdatePlatformFlagOnApps(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
name := "test_platform_update"
args := make(map[string]string)
args["dockerfile"] = "http://localhost/Dockerfile"
err = PlatformAdd(provision.PlatformOptions{Name: name})
c.Assert(err, check.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, check.IsNil)
defer conn.Apps().Remove(bson.M{"_id": appName})
err = PlatformUpdate(provision.PlatformOptions{Name: name, Args: args})
c.Assert(err, check.IsNil)
a, err := GetByName(appName)
c.Assert(err, check.IsNil)
c.Assert(a.UpdatePlatform, check.Equals, true)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:31,代码来源:platform_test.go
示例6: TestPlatformAdd
func (p *PlatformSuite) TestPlatformAdd(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
var buf bytes.Buffer
dockerfileURL := "http://localhost/Dockerfile"
writer := multipart.NewWriter(&buf)
writer.WriteField("name", "test")
writer.WriteField("dockerfile", dockerfileURL)
fileWriter, err := writer.CreateFormFile("dockerfile_content", "Dockerfile")
c.Assert(err, check.IsNil)
fileWriter.Write([]byte("FROM tsuru/java"))
writer.Close()
request, _ := http.NewRequest("POST", "/platforms/add", &buf)
request.Header.Add("Content-Type", writer.FormDataContentType())
recorder := httptest.NewRecorder()
token := createToken(c)
result := platformAdd(recorder, request, token)
c.Assert(result, check.IsNil)
b, err := ioutil.ReadAll(recorder.Body)
c.Assert(err, check.IsNil)
var msg io.SimpleJsonMessage
json.Unmarshal(b, &msg)
c.Assert(errors.New(msg.Error), check.ErrorMatches, "")
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:30,代码来源:platform_test.go
示例7: TestPlatformUpdateDisableFalseWithDockerfile
func (s *PlatformSuite) TestPlatformUpdateDisableFalseWithDockerfile(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
name := "test_platform_update"
args := make(map[string]string)
args["dockerfile"] = "http://localhost/Dockerfile"
args["disabled"] = "false"
err = PlatformAdd(name, nil, nil)
c.Assert(err, check.IsNil)
defer conn.Platforms().Remove(bson.M{"_id": name})
appName := "test_app_3"
app := App{
Name: appName,
Platform: name,
}
err = conn.Apps().Insert(app)
c.Assert(err, check.IsNil)
defer conn.Apps().Remove(bson.M{"_id": appName})
err = PlatformUpdate(name, args, nil)
c.Assert(err, check.IsNil)
a, err := GetByName(appName)
c.Assert(err, check.IsNil)
c.Assert(a.UpdatePlatform, check.Equals, true)
platf, err := getPlatform(name)
c.Assert(err, check.IsNil)
c.Assert(platf.Disabled, check.Equals, false)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:35,代码来源:platform_test.go
示例8: TestPlatformUpdateDisableFalseAndDockerfile
func (p *PlatformSuite) TestPlatformUpdateDisableFalseAndDockerfile(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
err := app.PlatformAdd(provision.PlatformOptions{Name: "wat", Args: nil, Output: nil})
c.Assert(err, check.IsNil)
dockerfile_url := "http://localhost/Dockerfile"
body := fmt.Sprintf("dockerfile=%s", dockerfile_url)
request, _ := http.NewRequest("PUT", "/platforms/wat?:name=wat&disabled=false", strings.NewReader(body))
request.Header.Add("Content-Type", "multipart/form-data")
recorder := httptest.NewRecorder()
token := createToken(c)
result := platformUpdate(recorder, request, token)
c.Assert(result, check.IsNil)
b, err := ioutil.ReadAll(recorder.Body)
c.Assert(err, check.IsNil)
var msg io.SimpleJsonMessage
json.Unmarshal(b, &msg)
c.Assert(errors.New(msg.Error), check.ErrorMatches, "")
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:25,代码来源:platform_test.go
示例9: TestPlatformWithAppsCantBeRemoved
func (s *PlatformSuite) TestPlatformWithAppsCantBeRemoved(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
name := "test_platform_update"
args := make(map[string]string)
args["dockerfile"] = "http://localhost/Dockerfile"
err = PlatformAdd(provision.PlatformOptions{Name: name})
c.Assert(err, check.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, check.IsNil)
defer conn.Apps().Remove(bson.M{"_id": appName})
err = PlatformRemove(name)
c.Assert(err, check.NotNil)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:28,代码来源:platform_test.go
示例10: TestPlatformRemoveAlwaysRemoveFromDB
func (s *PlatformSuite) TestPlatformRemoveAlwaysRemoveFromDB(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
conn, err := db.Conn()
c.Assert(err, check.IsNil)
defer conn.Close()
err = PlatformRemove("platform_dont_exists")
c.Assert(err, check.NotNil)
name := "test_platform_update"
args := make(map[string]string)
args["dockerfile"] = "http://localhost/Dockerfile"
err = PlatformAdd(provision.PlatformOptions{Name: name})
c.Assert(err, check.IsNil)
provisioner.PlatformRemove(name)
defer conn.Platforms().Remove(bson.M{"_id": name})
err = PlatformRemove(name)
c.Assert(err, check.IsNil)
count, err := conn.Platforms().Find(bson.M{"_id": name}).Count()
c.Assert(err, check.IsNil)
c.Assert(count, check.Equals, 0)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:26,代码来源:platform_test.go
示例11: SetUpTest
func (s *S) SetUpTest(c *check.C) {
routertest.FakeRouter.Reset()
repositorytest.Reset()
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
dbtest.ClearAllCollections(s.conn.Apps().Database)
s.logConn, err = db.LogConn()
c.Assert(err, check.IsNil)
s.createUserAndTeam(c)
s.provisioner = provisiontest.NewFakeProvisioner()
app.Provisioner = s.provisioner
app.AuthScheme = nativeScheme
p := app.Platform{Name: "zend"}
s.conn.Platforms().Insert(p)
s.Pool = "test1"
opts := provision.AddPoolOptions{Name: "test1", Default: true}
err = provision.AddPool(opts)
c.Assert(err, check.IsNil)
repository.Manager().CreateUser(s.user.Email)
repository.Manager().CreateUser(s.adminuser.Email)
factory, err := queue.Factory()
c.Assert(err, check.IsNil)
factory.Reset()
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:25,代码来源:suite_test.go
示例12: SetUpTest
func (s *ConsumptionSuite) SetUpTest(c *check.C) {
repositorytest.Reset()
config.Set("database:url", "127.0.0.1:27017")
config.Set("database:name", "tsuru_api_consumption_test")
config.Set("auth:hash-cost", 4)
config.Set("repo-manager", "fake")
var err error
s.conn, err = db.Conn()
c.Assert(err, check.IsNil)
dbtest.ClearAllCollections(s.conn.Apps().Database)
s.team = &auth.Team{Name: "tsuruteam"}
err = s.conn.Teams().Insert(s.team)
c.Assert(err, check.IsNil)
s.token = customUserWithPermission(c, "consumption-master-user", permission.Permission{
Scheme: permission.PermServiceInstance,
Context: permission.Context(permission.CtxTeam, s.team.Name),
}, permission.Permission{
Scheme: permission.PermServiceRead,
Context: permission.Context(permission.CtxTeam, s.team.Name),
})
s.user, err = s.token.User()
c.Assert(err, check.IsNil)
app.AuthScheme = nativeScheme
s.provisioner = provisiontest.NewFakeProvisioner()
app.Provisioner = s.provisioner
}
开发者ID:reoring,项目名称:tsuru,代码行数:26,代码来源:service_consumption_test.go
示例13: TestPlatformUpdateOnlyDisableTrue
func (s *PlatformSuite) TestPlatformUpdateOnlyDisableTrue(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
err := app.PlatformAdd(provision.PlatformOptions{Name: "wat", Args: nil, Output: nil})
c.Assert(err, check.IsNil)
dockerfileURL := ""
body := fmt.Sprintf("dockerfile=%s", dockerfileURL)
request, err := http.NewRequest("PUT", "/platforms/wat?disabled=true", strings.NewReader(body))
c.Assert(err, check.IsNil)
token := createToken(c)
request.Header.Add("Authorization", "b "+token.GetValue())
request.Header.Add("Content-Type", "multipart/form-data")
recorder := httptest.NewRecorder()
m := RunServer(true)
m.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/x-json-stream")
var msg io.SimpleJsonMessage
json.Unmarshal(recorder.Body.Bytes(), &msg)
c.Assert(errors.New(msg.Error), check.ErrorMatches, "")
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:27,代码来源:platform_test.go
示例14: TestPlatformUpdate
func (s *PlatformSuite) TestPlatformUpdate(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
oldProvisioner := app.Provisioner
app.Provisioner = &provisioner
defer func() {
app.Provisioner = oldProvisioner
}()
err := app.PlatformAdd(provision.PlatformOptions{Name: "wat", Args: nil, Output: nil})
c.Assert(err, check.IsNil)
var buf bytes.Buffer
dockerfileURL := "http://localhost/Dockerfile"
writer := multipart.NewWriter(&buf)
writer.WriteField("dockerfile", dockerfileURL)
writer.Close()
request, _ := http.NewRequest("PUT", "/platforms/wat", &buf)
request.Header.Add("Content-Type", writer.FormDataContentType())
token := createToken(c)
request.Header.Set("Authorization", "b "+token.GetValue())
recorder := httptest.NewRecorder()
m := RunServer(true)
m.ServeHTTP(recorder, request)
var msg io.SimpleJsonMessage
json.Unmarshal(recorder.Body.Bytes(), &msg)
c.Assert(errors.New(msg.Error), check.ErrorMatches, "")
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/x-json-stream")
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:28,代码来源:platform_test.go
示例15: SetUpTest
func (s *BindSuite) SetUpTest(c *check.C) {
routertest.FakeRouter.Reset()
dbtest.ClearAllCollections(s.conn.Apps().Database)
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 = provisiontest.NewFakeProvisioner()
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:9,代码来源:bind_test.go
示例16: TestShouldRegisterAllCommandsFromProvisioners
func (s *S) TestShouldRegisterAllCommandsFromProvisioners(c *check.C) {
fp := provisiontest.NewFakeProvisioner()
p := AdminCommandableProvisioner{FakeProvisioner: *fp}
provision.Register("fakeAdminProvisioner", &p)
manager := buildManager("tsuru-admin")
fake, ok := manager.Commands["fake-admin"]
c.Assert(ok, check.Equals, true)
c.Assert(fake, check.FitsTypeOf, &FakeAdminCommand{})
}
开发者ID:combor,项目名称:tsuru-admin,代码行数:9,代码来源:main_test.go
示例17: TestPlatformUpdateWithoutName
func (s *PlatformSuite) TestPlatformUpdateWithoutName(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
err := PlatformUpdate(provision.PlatformOptions{Name: ""})
c.Assert(err, check.Equals, ErrPlatformNameMissing)
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:11,代码来源:platform_test.go
示例18: TestShouldRegisterAllCommandsFromProvisioners
func (s *S) TestShouldRegisterAllCommandsFromProvisioners(c *check.C) {
fp := provisiontest.NewFakeProvisioner()
p := CommandableProvisioner{FakeProvisioner: *fp}
provision.Register("comm", &p)
manager := buildManager()
fake, ok := manager.Commands["fake"]
c.Assert(ok, check.Equals, true)
tsurudFake, ok := fake.(*tsurudCommand)
c.Assert(ok, check.Equals, true)
c.Assert(tsurudFake.Command, check.FitsTypeOf, &FakeCommand{})
}
开发者ID:zhenruyan,项目名称:tsuru,代码行数:11,代码来源:main_test.go
示例19: SetUpSuite
func (s *BindSuite) SetUpSuite(c *check.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, check.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 = provisiontest.NewFakeProvisioner()
}
开发者ID:keymon,项目名称:tsuru,代码行数:12,代码来源:bind_test.go
示例20: TestPlatformUpdateWithoutName
func (s *PlatformSuite) TestPlatformUpdateWithoutName(c *check.C) {
provisioner := provisiontest.ExtensibleFakeProvisioner{
FakeProvisioner: provisiontest.NewFakeProvisioner(),
}
Provisioner = &provisioner
defer func() {
Provisioner = s.provisioner
}()
err := PlatformUpdate(provision.PlatformOptions{Name: ""})
c.Assert(err, check.NotNil)
c.Assert(err.Error(), check.Equals, "Platform name is required.")
}
开发者ID:reoring,项目名称:tsuru,代码行数:12,代码来源:platform_test.go
注:本文中的github.com/tsuru/tsuru/provision/provisiontest.NewFakeProvisioner函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论