Skip to content

Commit 6bbaad8

Browse files
committed
fix: use TARGETARCH for building binaries in Dockerfiles and improve migration test handling
1 parent 407e2f0 commit 6bbaad8

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

gearbox-agent/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ARG COMMIT_SHA=unknown
1919
ARG BUILD_DATE=unknown
2020

2121
# Build the application with CGO disabled for static binary
22-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
22+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \
2323
-ldflags="-s -w -X main.Version=${VERSION} -X main.CommitSHA=${COMMIT_SHA} -X main.BuildDate=${BUILD_DATE}" \
2424
-o gearbox-agent \
2525
./cmd/gearbox-agent

gearbox-agent/internal/api/websocket_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ func TestWSHandler_HandleEvents(t *testing.T) {
8989
}
9090
defer conn.Close()
9191

92+
// Wait for subscription to register on the server side
93+
time.Sleep(50 * time.Millisecond)
94+
9295
// Publish an event
9396
testEvent := events.NewEvent(events.EventSyncStarted, map[string]interface{}{
9497
"test_key": "test_value",
@@ -135,6 +138,9 @@ func TestWSHandler_MultipleEvents(t *testing.T) {
135138
}
136139
defer conn.Close()
137140

141+
// Wait for subscription to register on the server side
142+
time.Sleep(50 * time.Millisecond)
143+
138144
// Publish multiple events
139145
eventTypes := []events.EventType{
140146
events.EventSyncStarted,

gearbox/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ARG COMMIT_SHA=unknown
3333
ARG BUILD_DATE=unknown
3434

3535
# Build the application with CGO enabled for sqlite3
36-
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
36+
RUN CGO_ENABLED=1 GOOS=linux GOARCH=${TARGETARCH} go build \
3737
-ldflags="-s -w -X main.Version=${VERSION} -X main.CommitSHA=${COMMIT_SHA} -X main.BuildDate=${BUILD_DATE}" \
3838
-o gearbox \
3939
./cmd/server

gearbox/internal/framework/database/database_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ func TestIsEntityDisabled(t *testing.T) {
198198
func TestMigrationSystemInitialization(t *testing.T) {
199199
db := setupTestDB(t)
200200

201+
// Check if migration files exist using the same logic as the migration manager
202+
mm := NewMigrateManager(db.db, db.logger)
203+
hasMigrations := mm.hasMigrationFiles()
204+
205+
if !hasMigrations {
206+
t.Skip("no migration files present, skipping migration verification")
207+
}
208+
201209
// Verify migration tracking table exists
202210
var count int
203211
err := db.db.QueryRow("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='schema_migrations'").Scan(&count)

0 commit comments

Comments
 (0)