Skip to content

Commit 79af90e

Browse files
mattmattoxclaude
andcommitted
Fix compilation errors and test issues
- Remove unused imports (log, config) - Fix test references to non-existent cache field - Rename 'types' variable to 'backupTypes' to avoid shadowing - Mark unused variable with underscore - Update Go version to 1.23 in CI pipeline - Fix test assertions for MySQL store 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 95f1d82 commit 79af90e

File tree

6 files changed

+13
-42
lines changed

6 files changed

+13
-42
lines changed

.github/workflows/pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v4
1919
with:
20-
go-version: "1.22"
20+
go-version: "1.23"
2121

2222
- name: Cache Go modules
2323
uses: actions/cache@v4

pkg/dbconfig/manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dbconfig
33

44
import (
55
"fmt"
6-
"log"
76
"time"
87

98
"github.com/google/uuid"

pkg/metadata/benchmark_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,18 @@ func createBenchmarkStore(size int) *Store {
147147
// Generate test data
148148
servers := []string{"server1", "server2", "server3", "server4", "server5"}
149149
databases := []string{"testdb", "proddb", "userdb", "orderdb", "logdb"}
150-
types := []string{"hourly", "daily", "weekly", "monthly", "manual"}
150+
backupTypes := []string{"hourly", "daily", "weekly", "monthly", "manual"}
151151
statuses := []types.BackupStatus{StatusSuccess, StatusError, StatusPending}
152152

153153
baseTime := time.Now().Add(-30 * 24 * time.Hour) // Start 30 days ago
154154

155155
for i := 0; i < size; i++ {
156156
backup := types.BackupMeta{
157-
ID: fmt.Sprintf("%s-%s-%s-%d", servers[i%5], databases[i%5], types[i%5], i),
157+
ID: fmt.Sprintf("%s-%s-%s-%d", servers[i%5], databases[i%5], backupTypes[i%5], i),
158158
ServerName: servers[i%5],
159159
ServerType: "mysql",
160160
Database: databases[i%5],
161-
BackupType: types[i%5],
161+
BackupType: backupTypes[i%5],
162162
CreatedAt: baseTime.Add(time.Duration(i) * time.Minute),
163163
CompletedAt: baseTime.Add(time.Duration(i)*time.Minute + 5*time.Minute),
164164
Size: int64(1024 * 1024 * (i%100 + 1)), // 1MB to 100MB

pkg/metadata/metadata_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestFileStorePartialWrite(t *testing.T) {
129129
}
130130

131131
// Add backup and save
132-
backup := store.CreateBackupMeta("server1", "mysql", "testdb", "daily")
132+
_ = store.CreateBackupMeta("server1", "mysql", "testdb", "daily")
133133
err = store.Save()
134134
require.NoError(t, err)
135135

pkg/metadata/mysql_store_optimized.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"log"
88
"time"
99

10-
"github.com/supporttools/GoSQLGuard/pkg/config"
1110
"github.com/supporttools/GoSQLGuard/pkg/metadata/types"
1211
"gorm.io/gorm"
1312
)

pkg/metadata/mysql_store_test.go

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ func TestMySQLStoreInitialization(t *testing.T) {
2020
// For now, we'll test the basic structure
2121

2222
dbStore := &DBStore{
23-
cache: MetadataStore{
24-
Backups: make([]types.BackupMeta, 0),
25-
Version: "1.0",
26-
LastUpdated: time.Now(),
27-
},
23+
db: nil, // Would be a mock in real test
24+
initialized: true,
2825
}
2926

3027
assert.NotNil(t, dbStore)
31-
assert.Equal(t, "1.0", dbStore.cache.Version)
32-
assert.Equal(t, 0, len(dbStore.cache.Backups))
28+
assert.True(t, dbStore.initialized)
3329
}
3430

3531
// TestMySQLStoreMockOperations tests MySQL operations with mocked database
@@ -49,12 +45,8 @@ func TestMySQLStoreMockOperations(t *testing.T) {
4945

5046
// Create DBStore
5147
dbStore := &DBStore{
52-
db: db,
53-
cache: MetadataStore{
54-
Backups: make([]types.BackupMeta, 0),
55-
Version: "1.0",
56-
LastUpdated: time.Now(),
57-
},
48+
db: db,
49+
initialized: true,
5850
}
5951

6052
// Test CreateBackupMeta
@@ -76,30 +68,11 @@ func TestMySQLStoreMockOperations(t *testing.T) {
7668
mock.ExpectCommit()
7769

7870
// Note: In real implementation, we'd need to handle the complex GORM queries
79-
// For now, we'll test the cache update
8071
err = dbStore.UpdateBackupStatus(backupID, types.StatusSuccess, map[string]string{"local": "/backup1"}, 1024, "")
8172

82-
// Since we're mocking, we'll manually update the cache for testing
83-
for i, b := range dbStore.cache.Backups {
84-
if b.ID == backupID {
85-
dbStore.cache.Backups[i].Status = types.StatusSuccess
86-
dbStore.cache.Backups[i].Size = 1024
87-
dbStore.cache.Backups[i].LocalPaths = map[string]string{"local": "/backup1"}
88-
break
89-
}
90-
}
91-
92-
// Verify the update
93-
found := false
94-
for _, b := range dbStore.cache.Backups {
95-
if b.ID == backupID {
96-
assert.Equal(t, types.StatusSuccess, b.Status)
97-
assert.Equal(t, int64(1024), b.Size)
98-
found = true
99-
break
100-
}
101-
}
102-
assert.True(t, found)
73+
// In a real test with a database, we would query to verify the update
74+
// For this mock test, we just ensure no error occurred
75+
assert.NoError(t, err)
10376
}
10477

10578
// TestMySQLStoreMigration tests migration from file to database

0 commit comments

Comments
 (0)