IsInCapsuleGroup binary search is case-sensitive broken (#181)

Co-authored-by: Maksim Fedotov <m_fedotov@wargaming.net>
This commit is contained in:
Maxim Fedotov
2021-01-05 13:10:27 +01:00
committed by GitHub
co-authored by Maksim Fedotov
parent 46a7a0b917
commit 4dc92451ea
2 changed files with 24 additions and 2 deletions
+1 -2
View File
@@ -18,7 +18,6 @@ package utils
import (
"sort"
"strings"
)
type UserGroupList []string
@@ -28,7 +27,7 @@ func (u UserGroupList) Len() int {
}
func (u UserGroupList) Less(i, j int) bool {
return strings.ToLower(u[i]) < strings.ToLower(u[j])
return u[i] < u[j]
}
func (u UserGroupList) Swap(i, j int) {
+23
View File
@@ -0,0 +1,23 @@
package utils
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsInCapsuleGroup(t *testing.T) {
groups := []string{
"DPS-QQ-DeparEE-Upload_RW",
"vsphere - glonqqqq-devopsq",
"OSAAA-WOO",
"crownuser-qq4",
"kubernetes-abilitytologin",
"waaazzz-prod-user",
"Zaxxxq_Global_Team_Leader_Automation",
}
capsuleGroup := "kubernetes-abilitytologin"
assert.True(t, UserGroupList(groups).IsInCapsuleGroup(capsuleGroup), nil)
}