本文整理汇总了Golang中github.com/tsuru/tsuru/app.DeployData.ID方法的典型用法代码示例。如果您正苦于以下问题:Golang DeployData.ID方法的具体用法?Golang DeployData.ID怎么用?Golang DeployData.ID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/app.DeployData
的用法示例。
在下文中一共展示了DeployData.ID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDeployInfoByAdminUser
func (s *DeploySuite) TestDeployInfoByAdminUser(c *check.C) {
a := app.App{Name: "g1", Platform: "python", Teams: []string{s.team.Name}}
user, _ := s.token.User()
err := app.CreateApp(&a, user)
c.Assert(err, check.IsNil)
defer app.Delete(&a, nil)
recorder := httptest.NewRecorder()
timestamp := time.Now()
duration := time.Duration(10e9)
previousDeploy := app.DeployData{App: "g1", Timestamp: timestamp.Add(-3600 * time.Second), Duration: duration, Commit: "e293e3e3me03ejm3puejmp3ej3iejop32", Error: ""}
err = s.conn.Deploys().Insert(previousDeploy)
c.Assert(err, check.IsNil)
lastDeploy := app.DeployData{App: "g1", Timestamp: timestamp, Duration: duration, Commit: "e82nn93nd93mm12o2ueh83dhbd3iu112", Error: ""}
err = s.conn.Deploys().Insert(lastDeploy)
c.Assert(err, check.IsNil)
defer s.conn.Deploys().RemoveAll(nil)
var d map[string]interface{}
err = s.conn.Deploys().Find(bson.M{"commit": lastDeploy.Commit}).One(&d)
c.Assert(err, check.IsNil)
lastDeployId := d["_id"].(bson.ObjectId).Hex()
url := fmt.Sprintf("/deploys/%s", lastDeployId)
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)
var result app.DeployData
err = json.Unmarshal(recorder.Body.Bytes(), &result)
c.Assert(err, check.IsNil)
lastDeploy.ID = d["_id"].(bson.ObjectId)
result.Timestamp = lastDeploy.Timestamp
result.RemoveDate = lastDeploy.RemoveDate
c.Assert(result, check.DeepEquals, lastDeploy)
}