Skip to content

Commit 3252e80

Browse files
committed
fix(tests): fix ClickHouse test context and regenerate AnalyzerV2 outputs
This commit fixes two issues: 1. ClickHouse end-to-end tests: Changed from managed-db context to a new clickhouse-specific context. The managed-db context only handles PostgreSQL, MySQL, and SQLite. ClickHouse tests now only run when a ClickHouse database is available. 2. AnalyzerV2 test outputs: The Experiment flag was not being passed to parseOpts in process.go and vet.go. This meant the AnalyzerV2 experiment was never actually active, even when tests configured SQLCEXPERIMENT. Now that the experiment is properly passed, the test expected outputs have been regenerated to match actual AnalyzerV2 behavior. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bc05612 commit 3252e80

File tree

11 files changed

+154
-144
lines changed

11 files changed

+154
-144
lines changed

internal/endtoend/endtoend_test.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func TestReplay(t *testing.T) {
113113
// t.Parallel()
114114
ctx := context.Background()
115115

116-
var mysqlURI, postgresURI string
116+
var mysqlURI, postgresURI, clickhouseURI string
117117

118118
// First, check environment variables
119119
if uri := os.Getenv("POSTGRESQL_SERVER_URI"); uri != "" {
@@ -122,6 +122,9 @@ func TestReplay(t *testing.T) {
122122
if uri := os.Getenv("MYSQL_SERVER_URI"); uri != "" {
123123
mysqlURI = uri
124124
}
125+
if uri := os.Getenv("CLICKHOUSE_SERVER_URI"); uri != "" {
126+
clickhouseURI = uri
127+
}
125128

126129
// Try Docker for any missing databases
127130
if postgresURI == "" || mysqlURI == "" {
@@ -146,7 +149,7 @@ func TestReplay(t *testing.T) {
146149
}
147150

148151
// Try native installation for any missing databases (Linux only)
149-
if postgresURI == "" || mysqlURI == "" {
152+
if postgresURI == "" || mysqlURI == "" || clickhouseURI == "" {
150153
if err := native.Supported(); err == nil {
151154
if postgresURI == "" {
152155
host, err := native.StartPostgreSQLServer(ctx)
@@ -164,12 +167,21 @@ func TestReplay(t *testing.T) {
164167
mysqlURI = host
165168
}
166169
}
170+
if clickhouseURI == "" {
171+
host, err := native.StartClickHouseServer(ctx)
172+
if err != nil {
173+
t.Logf("native clickhouse startup failed: %s", err)
174+
} else {
175+
clickhouseURI = host
176+
}
177+
}
167178
}
168179
}
169180

170181
// Log which databases are available
171182
t.Logf("PostgreSQL available: %v (URI: %s)", postgresURI != "", postgresURI)
172183
t.Logf("MySQL available: %v (URI: %s)", mysqlURI != "", mysqlURI)
184+
t.Logf("ClickHouse available: %v (URI: %s)", clickhouseURI != "", clickhouseURI)
173185

174186
contexts := map[string]textContext{
175187
"base": {
@@ -218,6 +230,22 @@ func TestReplay(t *testing.T) {
218230
return postgresURI != "" || mysqlURI != ""
219231
},
220232
},
233+
"clickhouse": {
234+
Mutate: func(t *testing.T, path string) func(*config.Config) {
235+
return func(c *config.Config) {
236+
for i := range c.SQL {
237+
if c.SQL[i].Engine == config.EngineClickHouse {
238+
c.SQL[i].Database = &config.Database{
239+
URI: clickhouseURI,
240+
}
241+
}
242+
}
243+
}
244+
},
245+
Enabled: func() bool {
246+
return clickhouseURI != ""
247+
},
248+
},
221249
}
222250

223251
for name, testctx := range contexts {

internal/endtoend/testdata/accurate_cte/postgresql/stdlib/go/models.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_cte/postgresql/stdlib/go/query.sql.go

Lines changed: 6 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_enum/postgresql/stdlib/go/models.go

Lines changed: 0 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_enum/postgresql/stdlib/go/query.sql.go

Lines changed: 33 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_sqlite/sqlite/stdlib/go/models.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_sqlite/sqlite/stdlib/go/query.sql.go

Lines changed: 31 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/accurate_star_expansion/postgresql/stdlib/go/models.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)