Skip to content

Commit

Permalink
fix broken GetInstanceAccount selector (#311)
Browse files Browse the repository at this point in the history
* fix broken GetInstanceAccount selector

* patch tests
  • Loading branch information
tsmethurst authored Nov 17, 2021
1 parent ff7c96c commit f3e36de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/db/bundb/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ func (a *accountDB) GetInstanceAccount(ctx context.Context, domain string) (*gts

q := a.newAccountQ(account)

if domain == "" {
if domain != "" {
q = q.
Where("account.username = ?", domain).
Where("account.domain = ?", domain)
} else {
q = q.
Where("account.username = ?", domain).
Where("account.username = ?", a.config.Host).
WhereGroup(" AND ", whereEmptyOrNull("domain"))
}

Expand Down
4 changes: 2 additions & 2 deletions internal/db/bundb/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (suite *AdminTestSuite) TestCreateInstanceAccount() {
testrig.CreateTestTables(suite.db)

// make sure there's no instance account in the db yet
acct, err := suite.db.GetInstanceAccount(context.Background(), suite.config.Host)
acct, err := suite.db.GetInstanceAccount(context.Background(), "")
suite.Error(err)
suite.Nil(acct)

Expand All @@ -46,7 +46,7 @@ func (suite *AdminTestSuite) TestCreateInstanceAccount() {
suite.NoError(err)

// and now check it exists
acct, err = suite.db.GetInstanceAccount(context.Background(), suite.config.Host)
acct, err = suite.db.GetInstanceAccount(context.Background(), "")
suite.NoError(err)
suite.NotNil(acct)
}
Expand Down

0 comments on commit f3e36de

Please sign in to comment.