commit f3e36de78aa9d13e74fabbb115bd7a20be57abaf
parent ff7c96caa312858fd253454993e363937155c608
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Wed, 17 Nov 2021 14:40:39 +0100
fix broken GetInstanceAccount selector (#311)
* fix broken GetInstanceAccount selector
* patch tests
Diffstat:
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go
@@ -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"))
}
diff --git a/internal/db/bundb/admin_test.go b/internal/db/bundb/admin_test.go
@@ -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)
@@ -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)
}