fix: close business flow regressions
This commit is contained in:
31
backend/api/internal/logic/gas/delivery_account_test.go
Normal file
31
backend/api/internal/logic/gas/delivery_account_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package gas
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func TestScopedDeliveryAccountsQualifiesJoinedStatusColumn(t *testing.T) {
|
||||
connection, _, err := sqlmock.New()
|
||||
if err != nil {
|
||||
t.Fatalf("create SQL mock: %v", err)
|
||||
}
|
||||
t.Cleanup(func() { _ = connection.Close() })
|
||||
databaseService, err := gorm.Open(postgres.New(postgres.Config{Conn: connection}), &gorm.Config{DryRun: true})
|
||||
if err != nil {
|
||||
t.Fatalf("open GORM database: %v", err)
|
||||
}
|
||||
|
||||
statement := scopedDeliveryAccounts(databaseService, 42).
|
||||
Find(&[]struct{}{}).Statement.SQL.String()
|
||||
if !strings.Contains(statement, "delivery_account.status <>") {
|
||||
t.Fatalf("joined query must qualify delivery account status, got: %s", statement)
|
||||
}
|
||||
if strings.Contains(statement, "WHERE status <>") {
|
||||
t.Fatalf("joined query contains ambiguous status column: %s", statement)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user