Fix Orgs.Join

This commit is contained in:
Joe Chen
2023-11-03 22:10:33 -04:00
parent e0a14a54fe
commit a44928493d

View File

@@ -157,10 +157,18 @@ func orgsSearchByName(t *testing.T, ctx context.Context, db *organizations) {
}
func orgsCountByUser(t *testing.T, ctx context.Context, db *organizations) {
// TODO: Use Orgs.Join to replace SQL hack when the method is available.
err := db.Exec(`INSERT INTO org_user (uid, org_id) VALUES (?, ?)`, 1, 1).Error
usersStore := NewUsersStore(db.DB)
alice, err := usersStore.Create(ctx, "alice", "alice@example.com", CreateUserOptions{})
require.NoError(t, err)
err = db.Exec(`INSERT INTO org_user (uid, org_id) VALUES (?, ?)`, 2, 1).Error
bob, err := usersStore.Create(ctx, "bob", "bob@example.com", CreateUserOptions{})
require.NoError(t, err)
tempPictureAvatarUploadPath := filepath.Join(os.TempDir(), "orgsList-tempPictureAvatarUploadPath")
conf.SetMockPicture(t, conf.PictureOpts{AvatarUploadPath: tempPictureAvatarUploadPath})
org1, err := db.Create(ctx, "org1", alice.ID, CreateOrganizationOptions{})
require.NoError(t, err)
err = db.AddMember(ctx, org1.ID, bob.ID)
require.NoError(t, err)
got, err := db.CountByUser(ctx, 1)