mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 04:26:45 +00:00
IsInCapsuleGroup binary search is case-sensitive broken (#181)
Co-authored-by: Maksim Fedotov <m_fedotov@wargaming.net>
This commit is contained in:
co-authored by
Maksim Fedotov
parent
46a7a0b917
commit
4dc92451ea
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user