Use ordered RemoveDuplicates. Add additional test cases.
This commit is contained in:
parent
a5b954658c
commit
ffbfe2da3d
@ -57,15 +57,15 @@ func StringFilter(fn FilterFn, in ...string) StringFilterWrapper {
|
||||
}
|
||||
|
||||
func RemoveDuplicates(in []string) []string {
|
||||
dedupMap := make(map[string]struct{})
|
||||
var found []string
|
||||
Outer:
|
||||
for _, i := range in {
|
||||
dedupMap[i] = struct{}{}
|
||||
for _, i2 := range found {
|
||||
if i2 == i {
|
||||
continue Outer
|
||||
}
|
||||
}
|
||||
found = append(found, i)
|
||||
}
|
||||
out := make([]string, len(dedupMap))
|
||||
i := 0
|
||||
for s := range dedupMap {
|
||||
out[i] = s
|
||||
i++
|
||||
}
|
||||
return out
|
||||
return found
|
||||
}
|
||||
|
||||
@ -102,6 +102,18 @@ func TestDNSNamesForCertificate(t *testing.T) {
|
||||
crtDNSNames: []string{"dnsname1", "dnsname2"},
|
||||
expectDNSNames: []string{"dnsname1", "dnsname2"},
|
||||
},
|
||||
{
|
||||
name: "certificate with dnsName[0] set to equal common name",
|
||||
crtCN: "cn",
|
||||
crtDNSNames: []string{"cn", "dnsname"},
|
||||
expectDNSNames: []string{"cn", "dnsname"},
|
||||
},
|
||||
{
|
||||
name: "certificate with a dnsName equal to cn",
|
||||
crtCN: "cn",
|
||||
crtDNSNames: []string{"dnsname", "cn"},
|
||||
expectDNSNames: []string{"cn", "dnsname"},
|
||||
},
|
||||
}
|
||||
testFn := func(test testT) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user