本文整理汇总了Golang中github.com/tsuru/tsuru/app.CreateApp函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateApp函数的具体用法?Golang CreateApp怎么用?Golang CreateApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDeployList
func (s *DeploySuite) TestDeployList(c *check.C) {
user, _ := s.token.User()
app1 := app.App{Name: "g1", Platform: "python", Teams: []string{s.team.Name}}
err := app.CreateApp(&app1, user)
c.Assert(err, check.IsNil)
defer app.Delete(&app1)
app2 := app.App{Name: "ge", Platform: "python", Teams: []string{s.team.Name}}
err = app.CreateApp(&app2, user)
c.Assert(err, check.IsNil)
defer app.Delete(&app2)
var result []app.DeployData
request, err := http.NewRequest("GET", "/deploys", nil)
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Date(2013, time.November, 1, 0, 0, 0, 0, time.Local)
duration := time.Since(timestamp)
err = s.conn.Deploys().Insert(app.DeployData{App: "g1", Timestamp: timestamp.Add(time.Minute), Duration: duration})
c.Assert(err, check.IsNil)
err = s.conn.Deploys().Insert(app.DeployData{App: "ge", Timestamp: timestamp.Add(time.Second), Duration: duration})
c.Assert(err, check.IsNil)
defer s.conn.Deploys().RemoveAll(nil)
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
c.Assert(result[0].ID, check.NotNil)
c.Assert(result[0].App, check.Equals, "g1")
c.Assert(result[0].Timestamp.In(time.UTC), check.DeepEquals, timestamp.Add(time.Minute).In(time.UTC))
c.Assert(result[0].Duration, check.DeepEquals, duration)
c.Assert(result[1].App, check.Equals, "ge")
c.Assert(result[1].Timestamp.In(time.UTC), check.DeepEquals, timestamp.Add(time.Second).In(time.UTC))
c.Assert(result[1].Duration, check.DeepEquals, duration)
}
示例2: TestDeployList
func (s *DeploySuite) TestDeployList(c *check.C) {
user, _ := s.token.User()
app1 := app.App{Name: "g1", Platform: "python", TeamOwner: s.team.Name}
err := app.CreateApp(&app1, user)
c.Assert(err, check.IsNil)
app2 := app.App{Name: "ge", Platform: "python", TeamOwner: s.team.Name}
err = app.CreateApp(&app2, user)
c.Assert(err, check.IsNil)
var result []app.DeployData
request, err := http.NewRequest("GET", "/deploys", nil)
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Date(2013, time.November, 1, 0, 0, 0, 0, time.Local)
deps := []app.DeployData{
{App: "g1", Timestamp: timestamp.Add(time.Minute)},
{App: "ge", Timestamp: timestamp.Add(time.Second)},
}
insertDeploysAsEvents(deps, c)
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/json")
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
c.Assert(result, check.HasLen, 2)
c.Assert(result[0].ID, check.NotNil)
c.Assert(result[0].App, check.Equals, "g1")
c.Assert(result[0].Timestamp.In(time.UTC), check.DeepEquals, timestamp.Add(time.Minute).In(time.UTC))
c.Assert(result[1].App, check.Equals, "ge")
c.Assert(result[1].Timestamp.In(time.UTC), check.DeepEquals, timestamp.Add(time.Second).In(time.UTC))
}
示例3: TestDeployRollbackHandlerWithInexistVersion
func (s *DeploySuite) TestDeployRollbackHandlerWithInexistVersion(c *check.C) {
user, _ := s.token.User()
a := app.App{Name: "otherapp", Platform: "python", TeamOwner: s.team.Name}
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
b := app.App{Name: "otherapp2", Platform: "python", TeamOwner: s.team.Name}
err = app.CreateApp(&b, user)
c.Assert(err, check.IsNil)
v := url.Values{}
v.Set("origin", "rollback")
v.Set("image", "v3")
u := fmt.Sprintf("/apps/%s/deploy/rollback", a.Name)
request, err := http.NewRequest("POST", u, strings.NewReader(v.Encode()))
c.Assert(err, check.IsNil)
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
recorder := httptest.NewRecorder()
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/x-json-stream")
c.Assert(recorder.Code, check.Equals, http.StatusOK)
var body map[string]string
err = json.Unmarshal(recorder.Body.Bytes(), &body)
c.Assert(err, check.IsNil)
c.Assert(body, check.DeepEquals, map[string]string{"Message": "", "Error": `invalid version: "v3"`})
}
示例4: TestRemoveServiceHandlerWIthAssociatedAppsWithNoUnbindAllListAllApp
func (s *ConsumptionSuite) TestRemoveServiceHandlerWIthAssociatedAppsWithNoUnbindAllListAllApp(c *check.C) {
var called int32
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "DELETE" && r.URL.Path == "/resources/my-mysql/bind" {
atomic.StoreInt32(&called, 1)
}
}))
defer ts.Close()
srvc := service.Service{Name: "mysql", Endpoint: map[string]string{"production": ts.URL}}
err := srvc.Create()
c.Assert(err, check.IsNil)
defer s.conn.Services().Remove(bson.M{"_id": "mysql"})
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)
a := app.App{
Name: "app",
Platform: "zend",
TeamOwner: s.team.Name,
}
ab := app.App{
Name: "app2",
Platform: "zend",
TeamOwner: s.team.Name,
}
err = app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
err = app.CreateApp(&ab, s.user)
c.Assert(err, check.IsNil)
units, _ := s.provisioner.AddUnits(&a, 1, "web", nil)
units, _ = s.provisioner.AddUnits(&ab, 1, "web", nil)
instance := service.ServiceInstance{
Name: "my-mysql",
ServiceName: "mysql",
Teams: []string{s.team.Name},
Apps: []string{"app", "app2"},
Units: []string{units[0].ID},
}
err = instance.Create()
c.Assert(err, check.IsNil)
defer s.conn.ServiceInstances().Remove(bson.M{"name": "my-mysql"})
recorder, request := makeRequestToRemoveInstanceHandlerWithNoUnbind("mysql", "my-mysql", c)
err = removeServiceInstance(recorder, request, s.token)
c.Assert(err, check.IsNil)
b, err := ioutil.ReadAll(recorder.Body)
c.Assert(err, check.IsNil)
var msg io.SimpleJsonMessage
json.Unmarshal(b, &msg)
c.Assert(msg.Error, check.Equals, service.ErrServiceInstanceBound.Error())
expectedMsg := "app,app2"
c.Assert(msg.Message, check.Equals, expectedMsg)
}
示例5: TestRebuildRoutesAfterSwap
func (s *S) TestRebuildRoutesAfterSwap(c *check.C) {
a1 := app.App{Name: "my-test-app-1", TeamOwner: s.team.Name}
err := app.CreateApp(&a1, s.user)
c.Assert(err, check.IsNil)
a2 := app.App{Name: "my-test-app-2", TeamOwner: s.team.Name}
err = app.CreateApp(&a2, s.user)
c.Assert(err, check.IsNil)
err = provisiontest.ProvisionerInstance.AddUnits(&a1, 3, "web", nil)
c.Assert(err, check.IsNil)
err = provisiontest.ProvisionerInstance.AddUnits(&a2, 2, "web", nil)
c.Assert(err, check.IsNil)
units1, err := a1.Units()
c.Assert(err, check.IsNil)
units2, err := a2.Units()
c.Assert(err, check.IsNil)
routertest.FakeRouter.AddRoute(a1.Name, &url.URL{Scheme: "http", Host: "invalid:1234"})
routertest.FakeRouter.RemoveRoute(a2.Name, units2[0].Address)
err = routertest.FakeRouter.Swap(a1.Name, a2.Name, false)
c.Assert(err, check.IsNil)
changes1, err := rebuild.RebuildRoutes(&a1)
c.Assert(err, check.IsNil)
changes2, err := rebuild.RebuildRoutes(&a2)
c.Assert(err, check.IsNil)
c.Assert(changes1.Added, check.IsNil)
c.Assert(changes1.Removed, check.DeepEquals, []string{"http://invalid:1234"})
c.Assert(changes2.Added, check.DeepEquals, []string{units2[0].Address.String()})
c.Assert(changes2.Removed, check.IsNil)
routes1, err := routertest.FakeRouter.Routes(a1.Name)
c.Assert(err, check.IsNil)
routes2, err := routertest.FakeRouter.Routes(a2.Name)
c.Assert(err, check.IsNil)
sort.Sort(URLList(routes1))
sort.Sort(URLList(routes2))
c.Assert(routes1, check.DeepEquals, []*url.URL{
units1[0].Address,
units1[1].Address,
units1[2].Address,
})
c.Assert(routes2, check.DeepEquals, []*url.URL{
units2[0].Address,
units2[1].Address,
})
c.Assert(routertest.FakeRouter.HasRoute(a1.Name, units2[0].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a1.Name, units2[1].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a2.Name, units1[0].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a2.Name, units1[1].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a2.Name, units1[2].Address.String()), check.Equals, true)
}
示例6: TestDeployWithCommitUserToken
func (s *DeploySuite) TestDeployWithCommitUserToken(c *check.C) {
user, _ := s.token.User()
a := app.App{
Name: "otherapp",
Platform: "python",
TeamOwner: s.team.Name,
Plan: app.Plan{Router: "fake"},
}
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
defer app.Delete(&a, nil)
url := fmt.Sprintf("/apps/%s/repository/clone?:appname=%s", a.Name, a.Name)
request, err := http.NewRequest("POST", url, strings.NewReader("archive-url=http://something.tar.gz&user=fulano&commit=123"))
c.Assert(err, check.IsNil)
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
recorder := httptest.NewRecorder()
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "text")
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Body.String(), check.Equals, "Archive deploy called\nOK\n")
deploys, err := s.conn.Deploys().Find(bson.M{"commit": "123"}).Count()
c.Assert(err, check.IsNil)
c.Assert(deploys, check.Equals, 0)
}
示例7: TestAssignRoleCheckGandalf
func (s *S) TestAssignRoleCheckGandalf(c *check.C) {
role, err := permission.NewRole("test", "app", "")
c.Assert(err, check.IsNil)
err = role.AddPermissions("app.deploy")
c.Assert(err, check.IsNil)
emptyToken := customUserWithPermission(c, "user2")
a := app.App{Name: "myapp", TeamOwner: s.team.Name}
err = app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
roleBody := bytes.NewBufferString(fmt.Sprintf("email=%s&context=myapp", emptyToken.GetUserName()))
req, err := http.NewRequest("POST", "/roles/test/user", roleBody)
c.Assert(err, check.IsNil)
token := customUserWithPermission(c, "user1", permission.Permission{
Scheme: permission.PermRoleUpdateAssign,
Context: permission.Context(permission.CtxGlobal, ""),
}, permission.Permission{
Scheme: permission.PermAppDeploy,
Context: permission.Context(permission.CtxApp, "myapp"),
})
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Authorization", "bearer "+token.GetValue())
recorder := httptest.NewRecorder()
server := RunServer(true)
server.ServeHTTP(recorder, req)
c.Assert(err, check.IsNil)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
emptyUser, err := emptyToken.User()
c.Assert(err, check.IsNil)
users, err := repositorytest.Granted("myapp")
c.Assert(err, check.IsNil)
c.Assert(users, check.DeepEquals, []string{s.user.Email, emptyToken.GetUserName()})
c.Assert(emptyUser.Roles, check.HasLen, 1)
}
示例8: TestListUnitsByAppHandler
func (s *S) TestListUnitsByAppHandler(c *check.C) {
a := app.App{Name: "myapp", Platform: "zend", TeamOwner: s.team.Name}
err := app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
err = a.AddUnits(2, "", nil)
c.Assert(err, check.IsNil)
req, err := http.NewRequest("GET", "/node/apps/myapp/containers", nil)
c.Assert(err, check.IsNil)
req.Header.Set("Authorization", "bearer "+s.token.GetValue())
rec := httptest.NewRecorder()
server := RunServer(true)
server.ServeHTTP(rec, req)
c.Assert(rec.Code, check.Equals, http.StatusOK)
body, err := ioutil.ReadAll(rec.Body)
c.Assert(err, check.IsNil)
var result []provision.Unit
var resultMap []map[string]interface{}
err = json.Unmarshal(body, &result)
c.Assert(err, check.IsNil)
err = json.Unmarshal(body, &resultMap)
c.Assert(err, check.IsNil)
c.Assert(result[0].ID, check.Equals, "myapp-0")
c.Assert(result[0].Type, check.Equals, "zend")
c.Assert(result[1].ID, check.Equals, "myapp-1")
c.Assert(result[1].Type, check.Equals, "zend")
c.Assert(resultMap[0]["HostAddr"], check.Equals, "10.10.10.1")
c.Assert(resultMap[1]["HostAddr"], check.Equals, "10.10.10.2")
c.Assert(resultMap[0]["HostPort"], check.Equals, "1")
c.Assert(resultMap[1]["HostPort"], check.Equals, "2")
c.Assert(resultMap[0]["IP"], check.Equals, "10.10.10.1")
c.Assert(resultMap[1]["IP"], check.Equals, "10.10.10.2")
}
示例9: TestDeployInfoByUserWithoutAccess
func (s *DeploySuite) TestDeployInfoByUserWithoutAccess(c *check.C) {
user := &auth.User{Email: "[email protected]", Password: "123456"}
app.AuthScheme = nativeScheme
_, err := nativeScheme.Create(user)
c.Assert(err, check.IsNil)
team := &auth.Team{Name: "team"}
err = s.conn.Teams().Insert(team)
c.Assert(err, check.IsNil)
a := app.App{Name: "g1", Platform: "python", TeamOwner: team.Name}
err = app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
token, err := nativeScheme.Login(map[string]string{"email": user.Email, "password": "123456"})
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Now()
depData := []app.DeployData{
{App: "g1", Timestamp: timestamp.Add(-3600 * time.Second), Commit: "e293e3e3me03ejm3puejmp3ej3iejop32", Error: "", Origin: "git"},
{App: "g1", Timestamp: timestamp, Commit: "e82nn93nd93mm12o2ueh83dhbd3iu112", Error: "", Origin: "git", Diff: "fake-diff"},
}
evts := insertDeploysAsEvents(depData, c)
url := fmt.Sprintf("/deploys/%s", evts[1].UniqueID.Hex())
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, check.IsNil)
request.Header.Set("Authorization", "bearer "+token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusNotFound)
body := recorder.Body.String()
c.Assert(body, check.Equals, "Deploy not found.\n")
}
示例10: TestDeployInfoDiff
func (s *DeploySuite) TestDeployInfoDiff(c *check.C) {
user, _ := s.token.User()
a := app.App{Name: "g1", Platform: "python", TeamOwner: s.team.Name}
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
recorder := httptest.NewRecorder()
timestamp := time.Now()
depData := []app.DeployData{
{App: "g1", Timestamp: timestamp.Add(-3600 * time.Second), Commit: "e293e3e3me03ejm3puejmp3ej3iejop32", Error: "", Origin: "git"},
{App: "g1", Timestamp: timestamp, Commit: "e82nn93nd93mm12o2ueh83dhbd3iu112", Error: "", Origin: "git", Diff: "fake-diff"},
}
lastDeploy := depData[1]
evts := insertDeploysAsEvents(depData, c)
url := fmt.Sprintf("/deploys/%s", evts[1].UniqueID.Hex())
request, err := http.NewRequest("GET", url, nil)
c.Assert(err, check.IsNil)
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/json")
lastDeploy.ID = evts[1].UniqueID
var result app.DeployData
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
result.Timestamp = lastDeploy.Timestamp
result.RemoveDate = lastDeploy.RemoveDate
result.Duration = 0
result.Log = ""
c.Assert(result, check.DeepEquals, lastDeploy)
}
示例11: TestDeployListByAppWithImage
func (s *DeploySuite) TestDeployListByAppWithImage(c *check.C) {
user, _ := s.token.User()
a := app.App{Name: "myblog", Platform: "python", TeamOwner: s.team.Name}
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
timestamp := time.Date(2013, time.November, 1, 0, 0, 0, 0, time.Local)
deploys := []app.DeployData{
{App: "myblog", Timestamp: timestamp, Image: "registry.tsuru.globoi.com/tsuru/app-example:v2", CanRollback: true},
{App: "yourblog", Timestamp: timestamp, Image: "127.0.0.1:5000/tsuru/app-tsuru-dashboard:v1", CanRollback: true},
}
insertDeploysAsEvents(deploys, c)
recorder := httptest.NewRecorder()
request, err := http.NewRequest("GET", "/deploys?app=myblog", nil)
c.Assert(err, check.IsNil)
request.Header.Set("Authorization", "bearer "+s.token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "application/json")
var result []app.DeployData
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
c.Assert(result, check.HasLen, 1)
c.Assert(result[0].Image, check.Equals, "v2")
c.Assert(result[0].App, check.Equals, "myblog")
c.Assert(result[0].Timestamp.In(time.UTC), check.DeepEquals, timestamp.In(time.UTC))
}
示例12: BenchmarkScanLogs
func (s *S) BenchmarkScanLogs(c *check.C) {
c.StopTimer()
var apps []app.App
for i := 0; i < 200; i++ {
a := app.App{Name: fmt.Sprintf("myapp-%d", i), Platform: "zend", TeamOwner: s.team.Name}
apps = append(apps, a)
err := app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
defer app.Delete(&a, nil)
}
baseMsg := `{"date": "2015-06-16T15:00:00.000Z", "message": "msg-%d", "source": "web", "appname": "%s", "unit": "unit1"}` + "\n"
for i := range apps {
// Remove overhead for first message from app from benchmark.
err := scanLogs(strings.NewReader(fmt.Sprintf(baseMsg, 0, apps[i].Name)))
c.Assert(err, check.IsNil)
}
r, w := io.Pipe()
go func() {
for i := 0; i < c.N; i++ {
msg := fmt.Sprintf(baseMsg, i, apps[i%len(apps)].Name)
_, err := w.Write([]byte(msg))
c.Assert(err, check.IsNil)
}
w.Close()
}()
c.StartTimer()
err := scanLogs(r)
c.Assert(err, check.IsNil)
c.StopTimer()
}
示例13: TestRebuildRoutesTCPRoutes
func (s *S) TestRebuildRoutesTCPRoutes(c *check.C) {
a := app.App{Name: "my-test-app", TeamOwner: s.team.Name}
err := app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
err = provisiontest.ProvisionerInstance.AddUnits(&a, 3, "web", nil)
c.Assert(err, check.IsNil)
units, err := a.Units()
c.Assert(err, check.IsNil)
for _, u := range units {
routertest.FakeRouter.RemoveRoute(a.Name, u.Address)
routertest.FakeRouter.AddRoute(a.Name, &url.URL{Scheme: "tcp", Host: u.Address.Host})
}
changes, err := rebuild.RebuildRoutes(&a)
c.Assert(err, check.IsNil)
c.Assert(changes.Added, check.IsNil)
c.Assert(changes.Removed, check.IsNil)
routes, err := routertest.FakeRouter.Routes(a.Name)
c.Assert(err, check.IsNil)
c.Assert(routes, check.HasLen, 3)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[0].Address.Host), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[1].Address.Host), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[2].Address.Host), check.Equals, true)
app, err := app.GetByName(a.Name)
c.Assert(err, check.IsNil)
addr, err := routertest.FakeRouter.Addr(app.Name)
c.Assert(err, check.IsNil)
c.Assert(app.Ip, check.Equals, addr)
}
示例14: TestRebuildRoutes
func (s *S) TestRebuildRoutes(c *check.C) {
a := app.App{Name: "my-test-app", TeamOwner: s.team.Name}
err := app.CreateApp(&a, s.user)
c.Assert(err, check.IsNil)
err = provisiontest.ProvisionerInstance.AddUnits(&a, 3, "web", nil)
c.Assert(err, check.IsNil)
units, err := a.Units()
c.Assert(err, check.IsNil)
routertest.FakeRouter.RemoveRoute(a.Name, units[2].Address)
routertest.FakeRouter.AddRoute(a.Name, &url.URL{Scheme: "http", Host: "invalid:1234"})
changes, err := rebuild.RebuildRoutes(&a)
c.Assert(err, check.IsNil)
c.Assert(changes.Added, check.DeepEquals, []string{units[2].Address.String()})
c.Assert(changes.Removed, check.DeepEquals, []string{"http://invalid:1234"})
routes, err := routertest.FakeRouter.Routes(a.Name)
c.Assert(err, check.IsNil)
c.Assert(routes, check.HasLen, 3)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[0].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[1].Address.String()), check.Equals, true)
c.Assert(routertest.FakeRouter.HasRoute(a.Name, units[2].Address.String()), check.Equals, true)
app, err := app.GetByName(a.Name)
c.Assert(err, check.IsNil)
addr, err := routertest.FakeRouter.Addr(app.Name)
c.Assert(err, check.IsNil)
c.Assert(app.Ip, check.Equals, addr)
}
示例15: TestDeployWithTokenForInternalAppName
func (s *DeploySuite) TestDeployWithTokenForInternalAppName(c *check.C) {
token, err := nativeScheme.AppLogin(app.InternalAppName)
c.Assert(err, check.IsNil)
a := app.App{
Name: "otherapp",
Platform: "python",
TeamOwner: s.team.Name,
Plan: app.Plan{Router: "fake"},
}
user, _ := s.token.User()
err = app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
defer app.Delete(&a, nil)
url := fmt.Sprintf("/apps/%s/repository/clone?:appname=%s", a.Name, a.Name)
request, err := http.NewRequest("POST", url, strings.NewReader("archive-url=http://something.tar.gz&user=fulano"))
c.Assert(err, check.IsNil)
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
recorder := httptest.NewRecorder()
request.Header.Set("Authorization", "bearer "+token.GetValue())
server := RunServer(true)
server.ServeHTTP(recorder, request)
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Header().Get("Content-Type"), check.Equals, "text")
c.Assert(recorder.Code, check.Equals, http.StatusOK)
c.Assert(recorder.Body.String(), check.Equals, "Archive deploy called\nOK\n")
}