Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Duffle create should output pretty JSON (#835)
Browse files Browse the repository at this point in the history
Signed-off-by: Radu M <root@radu.sh>
  • Loading branch information
Radu M authored Feb 21, 2020
1 parent 219867e commit ff921e4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
35 changes: 33 additions & 2 deletions cmd/duffle/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,40 @@ func TestCreateCmd(t *testing.T) {
}

// This is the Canonical JSON representation. http://wiki.laptop.org/go/Canonical_JSON
expected := `{"description":"A short description of your bundle","invocationImages":{"cnab":{"builder":"docker","configuration":{"registry":"deislabs"},"name":"cnab"}},"keywords":["test-bundle","cnab","tutorial"],"maintainers":[{"email":"john.doe@example.com","name":"John Doe","url":"https://example.com"},{"email":"jane.doe@example.com","name":"Jane Doe","url":"https://example.com"}],"name":"test-bundle","schemaVersion":"v1.0.0-WD","version":"0.1.0"}`
expected := `{
"name": "test-bundle",
"version": "0.1.0",
"schemaVersion": "v1.0.0-WD",
"description": "A short description of your bundle",
"keywords": [
"test-bundle",
"cnab",
"tutorial"
],
"maintainers": [
{
"email": "john.doe@example.com",
"name": "John Doe",
"url": "https://example.com"
},
{
"email": "jane.doe@example.com",
"name": "Jane Doe",
"url": "https://example.com"
}
],
"invocationImages": {
"cnab": {
"name": "cnab",
"builder": "docker",
"configuration": {
"registry": "deislabs"
}
}
}
}`

if string(mbytes) != expected {
t.Errorf("Expected duffle.json output to look like this:\n\n%s\n\nGot:\n\n%s", expected, string(mbytes))
t.Errorf("Expected duffle.json output to look like this:\n%s\nGot:\n%s", expected, string(mbytes))
}
}
2 changes: 1 addition & 1 deletion pkg/duffle/manifest/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Scaffold(path string) error {
},
}

d, err := json.MarshalCanonical(m)
d, err := json.MarshalIndent(m, "", "\t")
if err != nil {
return err
}
Expand Down

0 comments on commit ff921e4

Please sign in to comment.