package utils import ( "testing" ) type II interface { foo() } type TT struct { } func (t TT) foo() { } func TestDictKeysMan(t *testing.T) { testData := map[string]string{"k1": "v1", "k2": "v2"} result1 := DictKeysMan(testData, []string{"k1"}, nil).(map[string]interface{}) if _, ok := result1["k1"]; ok { t.Error("Params keysToRemove can not remove key!") } if _, ok := result1["k2"]; !ok { t.Error("Params keysToRemove removed wrong key!") } result2 := DictKeysMan([]interface{}{testData}, nil, []string{"k1"}).([]interface{}) result20 := result2[0].(map[string]interface{}) if _, ok := result20["k1"]; !ok { t.Error("Params keysToKeep can not keep key!") } if _, ok := result20["k2"]; ok { t.Error("Params keysToKeep keep wrong key!") } }