本文整理汇总了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")
}