mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
audit: add hashstructure
This commit is contained in:
45
audit/hashstructure_test.go
Normal file
45
audit/hashstructure_test.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHashWalker(t *testing.T) {
|
||||
replaceText := "foo"
|
||||
|
||||
cases := []struct {
|
||||
Input interface{}
|
||||
Output interface{}
|
||||
}{
|
||||
{
|
||||
map[string]interface{}{
|
||||
"hello": "foo",
|
||||
},
|
||||
map[string]interface{}{
|
||||
"hello": replaceText,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
map[string]interface{}{
|
||||
"hello": []interface{}{"world"},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"hello": []interface{}{replaceText},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
output, err := HashStructure(tc.Input, func(string) (string, error) {
|
||||
return replaceText, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s\n\n%#v", err, tc.Input)
|
||||
}
|
||||
if !reflect.DeepEqual(output, tc.Output) {
|
||||
t.Fatalf("bad:\n\n%#v\n\n%#v", tc.Input, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user