本文整理匯總了Golang中github.com/tsuru/tsuru/app.App.AddUnits方法的典型用法代碼示例。如果您正苦於以下問題:Golang App.AddUnits方法的具體用法?Golang App.AddUnits怎麽用?Golang App.AddUnits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsuru/tsuru/app.App
的用法示例。
在下文中一共展示了App.AddUnits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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")
}