Skip to content

Commit e8405b5

Browse files
authored
test: Enabled MySQL database (#3318)
* test: Enabled MySQL database * Remove invalid unique constraint * Fix schema, expect another error * Fix last test
1 parent fd91deb commit e8405b5

File tree

7 files changed

+19
-82
lines changed

7 files changed

+19
-82
lines changed

docker-compose.yml

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,12 @@ services:
1010
MYSQL_ROOT_PASSWORD: mysecretpassword
1111
MYSQL_ROOT_HOST: '%'
1212

13-
mysql5:
14-
image: "mysql/mysql-server:5.7"
15-
ports:
16-
- "3305:3306"
17-
restart: always
18-
environment:
19-
MYSQL_DATABASE: dinotest
20-
MYSQL_ROOT_PASSWORD: mysecretpassword
21-
MYSQL_ROOT_HOST: '%'
22-
profiles:
23-
- mysql
24-
2513
postgresql:
26-
image: "postgres:15"
14+
image: "postgres:16"
2715
ports:
2816
- "5432:5432"
2917
restart: always
3018
environment:
3119
POSTGRES_DB: postgres
3220
POSTGRES_PASSWORD: mysecretpassword
3321
POSTGRES_USER: postgres
34-
35-
postgresql14:
36-
image: "postgres:14"
37-
ports:
38-
- "5414:5432"
39-
restart: always
40-
environment:
41-
POSTGRES_DB: postgres
42-
POSTGRES_PASSWORD: mysecretpassword
43-
POSTGRES_USER: postgres
44-
profiles:
45-
- postgres
46-
47-
postgresql13:
48-
image: "postgres:13"
49-
ports:
50-
- "5413:5432"
51-
restart: always
52-
environment:
53-
POSTGRES_DB: postgres
54-
POSTGRES_PASSWORD: mysecretpassword
55-
POSTGRES_USER: postgres
56-
profiles:
57-
- postgres
58-
59-
postgresql12:
60-
image: "postgres:12"
61-
ports:
62-
- "5412:5432"
63-
restart: always
64-
environment:
65-
POSTGRES_DB: postgres
66-
POSTGRES_PASSWORD: mysecretpassword
67-
POSTGRES_USER: postgres
68-
profiles:
69-
- postgres
70-
71-
postgresql11:
72-
image: "postgres:11"
73-
ports:
74-
- "5411:5432"
75-
restart: always
76-
environment:
77-
POSTGRES_DB: postgres
78-
POSTGRES_PASSWORD: mysecretpassword
79-
POSTGRES_USER: postgres
80-
profiles:
81-
- postgres

internal/endtoend/endtoend_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ func TestReplay(t *testing.T) {
131131
c.SQL[i].Database = &config.Database{
132132
URI: uri,
133133
}
134-
// case config.EngineMySQL:
135-
// uri := local.MySQL(t, files)
136-
// c.SQL[i].Database = &config.Database{
137-
// URI: uri,
138-
// }
134+
case config.EngineMySQL:
135+
uri := local.MySQL(t, files)
136+
c.SQL[i].Database = &config.Database{
137+
URI: uri,
138+
}
139139
default:
140140
// pass
141141
}
@@ -146,9 +146,9 @@ func TestReplay(t *testing.T) {
146146
if len(os.Getenv("POSTGRESQL_SERVER_URI")) == 0 {
147147
return false
148148
}
149-
// if len(os.Getenv("MYSQL_SERVER_URI")) == 0 {
150-
// return false
151-
// }
149+
if len(os.Getenv("MYSQL_SERVER_URI")) == 0 {
150+
return false
151+
}
152152
return true
153153
},
154154
},

internal/endtoend/testdata/invalid_group_by_reference/mysql/query.sql

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
CREATE TABLE authors (
2-
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
3-
name text NOT NULL,
4-
bio text,
5-
UNIQUE(name)
6-
);
7-
81
-- name: ListAuthors :many
92
SELECT *
103
FROM authors
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE authors (
2+
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
name text NOT NULL,
4+
bio text
5+
);

internal/endtoend/testdata/invalid_group_by_reference/mysql/sqlc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"path": "go",
66
"engine": "mysql",
77
"name": "querytest",
8-
"schema": "query.sql",
8+
"schema": "schema.sql",
99
"queries": "query.sql"
1010
}
1111
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# package querytest
2-
query.sql:11:10: column reference "invalid_reference" not found
2+
query.sql:4:10: column reference "invalid_reference" not found

internal/endtoend/testdata/valid_group_by_reference/mysql/schema.sql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
CREATE TABLE authors (
2-
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
3-
name VARCHAR(10) NOT NULL,
4-
bio text,
5-
UNIQUE(name)
2+
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
name VARCHAR(10) NOT NULL,
4+
bio text
65
);
76

87
CREATE TABLE IF NOT EXISTS weather_metrics

0 commit comments

Comments
 (0)