зеркало из https://github.com/getsops/sops.git
This commit is contained in:
Родитель
46fc619a9d
Коммит
401d8cf474
|
@ -25,9 +25,15 @@ func (store Store) sliceFromJSONDecoder(dec *json.Decoder) ([]interface{}, error
|
|||
}
|
||||
if delim, ok := t.(json.Delim); ok && delim.String() == "]" {
|
||||
return slice, nil
|
||||
} else if ok && delim.String() == "{" {
|
||||
item, err := store.treeBranchFromJSONDecoder(dec)
|
||||
if err != nil {
|
||||
return slice, err
|
||||
}
|
||||
slice = append(slice, item)
|
||||
} else {
|
||||
slice = append(slice, t)
|
||||
}
|
||||
|
||||
slice = append(slice, t)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,32 @@ func TestDecodeJSONWithArray(t *testing.T) {
|
|||
assert.Equal(t, expected, branch)
|
||||
}
|
||||
|
||||
func TestDecodeJSONArrayOfObjects(t *testing.T) {
|
||||
in := `{"foo": [{"bar": "foo"}, {"foo": "bar"}]}`
|
||||
expected := sops.TreeBranch{
|
||||
sops.TreeItem{
|
||||
Key: "foo",
|
||||
Value: []interface{}{
|
||||
sops.TreeBranch{
|
||||
sops.TreeItem{
|
||||
Key: "bar",
|
||||
Value: "foo",
|
||||
},
|
||||
},
|
||||
sops.TreeBranch{
|
||||
sops.TreeItem{
|
||||
Key: "foo",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
branch, err := Store{}.treeBranchFromJSON([]byte(in))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, expected, branch)
|
||||
}
|
||||
|
||||
func TestEncodeSimpleJSON(t *testing.T) {
|
||||
branch := sops.TreeBranch{
|
||||
sops.TreeItem{
|
||||
|
|
Загрузка…
Ссылка в новой задаче