mirror of https://github.com/docker/compose.git
Fix tests
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
ef5e013aa7
commit
fb59c9385d
|
@ -31,7 +31,7 @@ func TestVersionFormat(t *testing.T) {
|
||||||
jsonCases := []caze{
|
jsonCases := []caze{
|
||||||
{
|
{
|
||||||
Actual: fixedJSONArgs([]string{}),
|
Actual: fixedJSONArgs([]string{}),
|
||||||
Expected: nil,
|
Expected: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Actual: fixedJSONArgs([]string{
|
Actual: fixedJSONArgs([]string{
|
||||||
|
@ -103,7 +103,7 @@ func TestVersionFormat(t *testing.T) {
|
||||||
prettyCases := []caze{
|
prettyCases := []caze{
|
||||||
{
|
{
|
||||||
Actual: fixedPrettyArgs([]string{}),
|
Actual: fixedPrettyArgs([]string{}),
|
||||||
Expected: nil,
|
Expected: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Actual: fixedPrettyArgs([]string{
|
Actual: fixedPrettyArgs([]string{
|
||||||
|
@ -172,7 +172,7 @@ func TestVersionFormat(t *testing.T) {
|
||||||
"--format",
|
"--format",
|
||||||
"pretty",
|
"pretty",
|
||||||
}),
|
}),
|
||||||
Expected: nil,
|
Expected: []string{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,12 @@ package formatter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const standardIndentation = " "
|
const standardIndentation = " "
|
||||||
|
|
||||||
// ToStandardJSON return a string with the JSON representation of the interface{}
|
// ToStandardJSON return a string with the JSON representation of the interface{}
|
||||||
func ToStandardJSON(i interface{}) (string, error) {
|
func ToStandardJSON(i interface{}) (string, error) {
|
||||||
if reflect.ValueOf(i).IsNil() {
|
|
||||||
return "{}", nil
|
|
||||||
}
|
|
||||||
b, err := json.MarshalIndent(i, "", standardIndentation)
|
b, err := json.MarshalIndent(i, "", standardIndentation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue