Hackaton: Add more unit tests, take 2 (#101473)
* login/social/socialimpl: add assertions for usage stats, support bundle and oauthinfo methods * accesscontrol/acimpl: add tests for GetRoleByName * anonymous/sortopts: add tests for Sorter * cloudmigration/gmsclient: add basic test cases for all methods * shorturls/shorturlimpl: add more edge test cases * tag/tagimpl: add test to cover duplicate tag kv and nil pairs * updatechecker: add test cases for module
This commit is contained in:
@@ -78,6 +78,12 @@ func TestParseTagPairs(t *testing.T) {
|
||||
assert.Equal(t, "key", tags[2].Key)
|
||||
assert.Equal(t, "val2", tags[2].Value)
|
||||
})
|
||||
|
||||
t.Run("Nil tag returns an allocated but empty pair", func(t *testing.T) {
|
||||
tags := ParseTagPairs(nil)
|
||||
require.NotNil(t, tags)
|
||||
require.Empty(t, tags)
|
||||
})
|
||||
}
|
||||
|
||||
func TestJoinTagPairs(t *testing.T) {
|
||||
|
||||
@@ -26,10 +26,12 @@ func testIntegrationSavingTags(t *testing.T, fn getStore) {
|
||||
{Key: "outage"},
|
||||
{Key: "type", Value: "outage"},
|
||||
{Key: "server", Value: "server-1"},
|
||||
{Key: "server", Value: "server-1"}, // duplicates will generate a new ID.
|
||||
{Key: "error"},
|
||||
{Key: "error"}, // duplicates will generate a new ID.
|
||||
}
|
||||
tags, err := store.EnsureTagsExist(context.Background(), tagPairs)
|
||||
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, 4, len(tags))
|
||||
require.Equal(t, len(tagPairs), len(tags))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user