Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4d8424

Browse files
authored
fix: fix GetOrganizationsByUserID error when multiple organizations exist (#12257)
* test: fetching user orgs fails if multi orgs in pg db* fix: GetOrganizationsByUserID fixed if multi orgs exist
1 parentda37654 commitd4d8424

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

‎coderd/database/queries.sql.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/organizations.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ SELECT
3838
FROM
3939
organizations
4040
WHERE
41-
id= (
41+
id=ANY(
4242
SELECT
4343
organization_id
4444
FROM

‎coderd/organizations_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ import (
1212
"github.com/coder/coder/v2/testutil"
1313
)
1414

15+
funcTestMultiOrgFetch(t*testing.T) {
16+
t.Parallel()
17+
client:=coderdtest.New(t,nil)
18+
_=coderdtest.CreateFirstUser(t,client)
19+
20+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
21+
defercancel()
22+
23+
makeOrgs:= []string{"foo","bar","baz"}
24+
for_,name:=rangemakeOrgs {
25+
_,err:=client.CreateOrganization(ctx, codersdk.CreateOrganizationRequest{
26+
Name:name,
27+
})
28+
require.NoError(t,err)
29+
}
30+
31+
orgs,err:=client.OrganizationsByUser(ctx,codersdk.Me)
32+
require.NoError(t,err)
33+
require.NotNil(t,orgs)
34+
require.Len(t,orgs,len(makeOrgs)+1)
35+
}
36+
1537
funcTestOrganizationsByUser(t*testing.T) {
1638
t.Parallel()
1739
client:=coderdtest.New(t,nil)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp