diff options
Diffstat (limited to 'internal/db/org_users_test.go')
-rw-r--r-- | internal/db/org_users_test.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/db/org_users_test.go b/internal/db/org_users_test.go index f5c486db..ff7cd7b2 100644 --- a/internal/db/org_users_test.go +++ b/internal/db/org_users_test.go @@ -5,8 +5,10 @@ package db import ( + "context" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "gogs.io/gogs/internal/dbtest" @@ -43,9 +45,19 @@ func TestOrgUsers(t *testing.T) { } func orgUsersCountByUser(t *testing.T, db *orgUsers) { + ctx := context.Background() + // TODO: Use OrgUsers.Join to replace SQL hack when the method is available. err := db.Exec(`INSERT INTO org_user (uid, org_id) VALUES (?, ?)`, 1, 1).Error require.NoError(t, err) err = db.Exec(`INSERT INTO org_user (uid, org_id) VALUES (?, ?)`, 2, 1).Error require.NoError(t, err) + + got, err := db.CountByUser(ctx, 1) + require.NoError(t, err) + assert.Equal(t, int64(1), got) + + got, err = db.CountByUser(ctx, 404) + require.NoError(t, err) + assert.Equal(t, int64(0), got) } |