Skip to content

Commit 2f47494

Browse files
authored
test: remove stale current_accounts DDL from service test helpers (#1219)
The service test setup functions contained a dead CREATE TABLE for current_accounts with the old schema (currency VARCHAR(3)). The actual persistence layer uses an 'account' table auto-migrated by GORM from CurrentAccountEntity, which already uses instrument_code/dimension. Remove the unused current_accounts table DDL from four test setup functions across grpc_service_test, grpc_service_integration_test, grpc_service_party_integration_test, and lien_service_test. Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>
1 parent be5d6ba commit 2f47494

4 files changed

Lines changed: 1 addition & 65 deletions

File tree

services/current-account/service/grpc_service_integration_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,6 @@ func setupIntegrationTestDB(t *testing.T) (*gorm.DB, context.Context, func()) {
438438
err := db.Exec(fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %s", pq.QuoteIdentifier(schemaName))).Error
439439
require.NoError(t, err)
440440

441-
// Create the current_accounts table in the tenant schema
442-
err = db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.current_accounts (
443-
id UUID PRIMARY KEY,
444-
account_number VARCHAR(255) NOT NULL UNIQUE,
445-
party_id UUID NOT NULL,
446-
currency VARCHAR(3) NOT NULL,
447-
balance_cents BIGINT NOT NULL DEFAULT 0,
448-
status VARCHAR(20) NOT NULL,
449-
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
450-
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
451-
version INT NOT NULL DEFAULT 1,
452-
created_by VARCHAR(255),
453-
updated_by VARCHAR(255)
454-
)`, pq.QuoteIdentifier(schemaName))).Error
455-
require.NoError(t, err)
456-
457441
// Set default search_path to include tenant schema
458442
err = db.Exec(fmt.Sprintf("SET search_path TO %s, public", pq.QuoteIdentifier(schemaName))).Error
459443
require.NoError(t, err)

services/current-account/service/grpc_service_party_integration_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,6 @@ func setupPartyIntegrationTestDB(t *testing.T) (*gorm.DB, context.Context, func(
138138
err := db.Exec(fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %s", pq.QuoteIdentifier(schemaName))).Error
139139
require.NoError(t, err)
140140

141-
// Create the current_accounts table in the tenant schema
142-
err = db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.current_accounts (
143-
id UUID PRIMARY KEY,
144-
account_number VARCHAR(255) NOT NULL UNIQUE,
145-
party_id UUID NOT NULL,
146-
currency VARCHAR(3) NOT NULL,
147-
balance_cents BIGINT NOT NULL DEFAULT 0,
148-
status VARCHAR(20) NOT NULL,
149-
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
150-
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
151-
version INT NOT NULL DEFAULT 1,
152-
created_by VARCHAR(255),
153-
updated_by VARCHAR(255)
154-
)`, pq.QuoteIdentifier(schemaName))).Error
155-
require.NoError(t, err)
156-
157141
// Set default search_path to include tenant schema
158142
err = db.Exec(fmt.Sprintf("SET search_path TO %s, public", pq.QuoteIdentifier(schemaName))).Error
159143
require.NoError(t, err)

services/current-account/service/grpc_service_test.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -314,23 +314,7 @@ func setupTestDB(t *testing.T) (*gorm.DB, context.Context, func()) {
314314
err := db.Exec(fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %s", pq.QuoteIdentifier(schemaName))).Error
315315
require.NoError(t, err)
316316

317-
// Create the current_accounts table in the tenant schema
318-
err = db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.current_accounts (
319-
id UUID PRIMARY KEY,
320-
account_number VARCHAR(255) NOT NULL UNIQUE,
321-
party_id UUID NOT NULL,
322-
currency VARCHAR(3) NOT NULL,
323-
balance_cents BIGINT NOT NULL DEFAULT 0,
324-
status VARCHAR(20) NOT NULL,
325-
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
326-
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
327-
version INT NOT NULL DEFAULT 1,
328-
created_by VARCHAR(255),
329-
updated_by VARCHAR(255)
330-
)`, pq.QuoteIdentifier(schemaName))).Error
331-
require.NoError(t, err)
332-
333-
// Set default search_path to include tenant schema
317+
// Set default search_path to include tenant schema so queries route to tenant-scoped tables
334318
err = db.Exec(fmt.Sprintf("SET search_path TO %s, public", pq.QuoteIdentifier(schemaName))).Error
335319
require.NoError(t, err)
336320

services/current-account/service/lien_service_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,6 @@ func setupLienTestDB(t *testing.T) (*gorm.DB, context.Context, func()) {
4343
err := db.Exec(fmt.Sprintf("CREATE SCHEMA IF NOT EXISTS %s", pq.QuoteIdentifier(schemaName))).Error
4444
require.NoError(t, err)
4545

46-
// Create the current_accounts table in the tenant schema
47-
err = db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.current_accounts (
48-
id UUID PRIMARY KEY,
49-
account_number VARCHAR(255) NOT NULL UNIQUE,
50-
party_id UUID NOT NULL,
51-
currency VARCHAR(3) NOT NULL,
52-
balance_cents BIGINT NOT NULL DEFAULT 0,
53-
status VARCHAR(20) NOT NULL,
54-
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
55-
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
56-
version INT NOT NULL DEFAULT 1,
57-
created_by VARCHAR(255),
58-
updated_by VARCHAR(255)
59-
)`, pq.QuoteIdentifier(schemaName))).Error
60-
require.NoError(t, err)
61-
6246
// Create the lien table in the tenant schema
6347
err = db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.lien (
6448
id UUID PRIMARY KEY,

0 commit comments

Comments
 (0)