File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -607,7 +607,7 @@ func TestSanitizeNodeName(t *testing.T) {
607607 want string
608608 }{
609609 {"My GPU Box" , "my-gpu-box" },
610- {"pratik -ec2" , "pratik -ec2" },
610+ {"my -ec2" , "my -ec2" },
611611 {"already-clean" , "already-clean" },
612612 {"UPPER CASE" , "upper-case" },
613613 {"special!@#chars" , "special-chars" },
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ func (s AuthHTTPStore) GetOrganizations(options *GetOrganizationsOptions) ([]ent
123123
124124 filteredOrgs := []entity.Organization {}
125125 for _ , o := range orgs {
126- if o .Name == options .Name {
126+ if strings . EqualFold ( o .Name , options .Name ) {
127127 filteredOrgs = append (filteredOrgs , o )
128128 }
129129 }
Original file line number Diff line number Diff line change @@ -50,6 +50,42 @@ func TestGetOrganizations(t *testing.T) {
5050 }
5151}
5252
53+ func TestGetOrganizationsFiltersNameCaseInsensitive (t * testing.T ) {
54+ fs := MakeMockAuthHTTPStore ()
55+ httpmock .ActivateNonDefault (fs .authHTTPClient .restyClient .GetClient ())
56+ defer httpmock .DeactivateAndReset ()
57+
58+ expected := []entity.Organization {{
59+ ID : "1" ,
60+ Name : "TEST" ,
61+ }}
62+ orgs := []entity.Organization {
63+ expected [0 ],
64+ {
65+ ID : "2" ,
66+ Name : "Other" ,
67+ },
68+ }
69+ res , err := httpmock .NewJsonResponder (200 , orgs )
70+ if ! assert .Nil (t , err ) {
71+ return
72+ }
73+ url := fmt .Sprintf ("%s/%s" , fs .authHTTPClient .restyClient .BaseURL , orgPath )
74+ httpmock .RegisterResponder ("GET" , url , res )
75+
76+ org , err := fs .GetOrganizations (& GetOrganizationsOptions {Name : "test" })
77+ if ! assert .Nil (t , err ) {
78+ return
79+ }
80+ if ! assert .NotNil (t , org ) {
81+ return
82+ }
83+
84+ if ! assert .Equal (t , expected , org ) {
85+ return
86+ }
87+ }
88+
5389func TestCreateOrganization (t * testing.T ) {
5490 fs := MakeMockAuthHTTPStore ()
5591 httpmock .ActivateNonDefault (fs .authHTTPClient .restyClient .GetClient ())
You can’t perform that action at this time.
0 commit comments