Fixed JSON error in mocks

This commit is contained in:
DazWilkin 2016-08-01 19:43:43 -07:00
parent 5a15d606a7
commit fdf28732d7
1 changed files with 14 additions and 15 deletions

View File

@ -11,7 +11,7 @@ import (
const dockerid = "somerandomuser" const dockerid = "somerandomuser"
const hexBytes = "0123456789abcdef" const hexBytes = "0123456789abcdef"
const imagename = "testimage" const imagename = "testimage"
const registry = "https://registry.hub.docker.com" const registry = "https://registry.hub.docker.com/u/"
func init() { func init() {
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
@ -27,39 +27,38 @@ func RandStringBytes(n int) string {
func NewEventJSONEncoded() string { func NewEventJSONEncoded() string {
return fmt.Sprintf(`{ return fmt.Sprintf(`{
"callback_url": %s, "callback_url": "%s",
"push_data": { "push_data": {
"images": [ "images": [
%s, "%s",
%s, "%s"
], ],
"pushed_at" %v, "pushed_at": %v,
"pusher": %s "pusher": "%s"
}, },
"repository": { "repository": {
"comment_count": "0", "comment_count": 0,
"date_created": %v, "date_created": %v,
"description: "", "description": "",
"dockerfile": "", "dockerfile": "",
"is_official": false, "is_official": false,
"is_private": true, "is_private": true,
"is_trusted": true, "is_trusted": true,
"name": "testhook", "name": "testhook",
"namespace": "dazwilkin", "namespace": "telegraf",
"owner": %s, "owner": "%s",
"repo_name": "dazwilkin/testwebhook", "repo_name": "%s",
"repo_url": %s, "repo_url": "%s",
"star_count": 0, "star_count": 0,
"status": "Active" "status": "Active"
} }
}`, }`,
registry, fmt.Sprintf("%s/%s/%s/%s/", registry, dockerid, imagename, RandStringBytes(64)),
RandStringBytes(64), RandStringBytes(64),
RandStringBytes(64), RandStringBytes(64),
time.Now().Unix(), time.Now().Unix(),
dockerid, dockerid,
time.Now().Unix(), time.Now().Unix(),
dockerid, dockerid,
fmt.Sprintf("%s/%s", dockerid, imagename), fmt.Sprintf("%s/%s", dockerid, imagename))
fmt.Sprintf("%s/u/%s/%s", registry, dockerid, imagename))
} }