Skip to content

Commit 5bd5770

Browse files
author
jennybuckley
committed
Add unstructured roundtrip test
1 parent 1cf8046 commit 5bd5770

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/cli/main_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package cli
1818

1919
import (
2020
"bytes"
21+
"encoding/json"
2122
"io/ioutil"
2223
"path/filepath"
2324
"testing"
@@ -233,6 +234,18 @@ func TestFieldSet(t *testing.T) {
233234
t.Errorf("unexpected error: %v", err)
234235
}
235236
tt.checkOutput(t, b.Bytes())
237+
238+
// Test that round tripping through unstructured will preserve ordering
239+
u := map[string]interface{}{}
240+
err = json.Unmarshal(b.Bytes(), &u)
241+
if err != nil {
242+
t.Errorf("unexpected error: %v", err)
243+
}
244+
m, err := json.Marshal(&u)
245+
if err != nil {
246+
t.Errorf("unexpected error: %v", err)
247+
}
248+
tt.checkOutput(t, m)
236249
})
237250
}
238251
}

0 commit comments

Comments
 (0)