Skip to content
Snippets Groups Projects
Commit 8ac1e952 authored by ensiouel's avatar ensiouel
Browse files

добавлены тесты для Set

parent f4d46cb1
No related branches found
No related tags found
No related merge requests found
......@@ -247,6 +247,8 @@ func TestSearch(t *testing.T) {
}
func TestSet(t *testing.T) {
var uninitializedMap map[string]any
type args struct {
field string
data any
......@@ -266,6 +268,8 @@ func TestSet(t *testing.T) {
{"Map value", args{"a", map[string]interface{}{"a": "0"}, map[string]interface{}{"a": "a"}}, map[string]interface{}{"a": map[string]interface{}{"a": "a"}}, assert.NoError},
{"Slice", args{"a.a", map[string]interface{}{"a": []any{map[string]any{"a": "0"}, map[string]any{"a": "0", "b": "b"}}}, "a"}, map[string]interface{}{"a": []any{map[string]any{"a": "a"}, map[string]any{"a": "a", "b": "b"}}}, assert.NoError},
{"Slice", args{"a.0.a", map[string]interface{}{"a": []any{map[string]any{"a": "0"}, map[string]any{"a": "0", "b": "b"}}}, "a"}, map[string]interface{}{"a": []any{map[string]any{"a": "a"}, map[string]any{"a": "0", "b": "b"}}}, assert.NoError},
{"Set the object for the uninitialized map", args{"a", uninitializedMap, "a"}, uninitializedMap, assert.NoError},
{"Set the object field for the uninitialized map", args{"a.b", uninitializedMap, "a"}, uninitializedMap, assert.NoError},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment