Skip to content

Commit

Permalink
More cases for merge dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobht committed Nov 6, 2024
1 parent 3df541e commit 0841f83
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions internal/common/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ import (
)

func Test_MergeDicts(t *testing.T) {
dic1 := map[string]string{"a": "1", "b": "2"}
dic2 := map[string]string{"b": "3", "c": "4"}
expected := map[string]string{"a": "1", "b": "3", "c": "4"}
cases := []struct {
dic1 map[string]string
dic2 map[string]string
expected map[string]string
}{
{map[string]string{"a": "1", "b": "2"}, map[string]string{"b": "3", "c": "4"}, map[string]string{"a": "1", "b": "3", "c": "4"}},
{map[string]string{"a": "1"}, map[string]string{"a": "2"}, map[string]string{"a": "2"}},
{map[string]string{}, map[string]string{"a": "1"}, map[string]string{"a": "1"}},
{map[string]string{"a": "1"}, map[string]string{}, map[string]string{"a": "1"}},
{map[string]string{}, map[string]string{}, map[string]string{}},
}

result := MergeDicts(dic1, dic2)
assert.Equal(t, expected, result)
for _, c := range cases {
result := MergeDicts(c.dic1, c.dic2)
assert.Equal(t, c.expected, result)
}
}

func Test_AwaitWaitGroup(t *testing.T) {
Expand Down

0 comments on commit 0841f83

Please sign in to comment.