Skip to content

Commit ea53432

Browse files
committed
Enable PostgreSQL tests in GitHub Actions
1 parent 66f830c commit ea53432

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
<p align="center">
33

4-
[![Build Status](https://travis-ci.com/wind-c/comqtt.svg?token=59nqixhtefy2iQRwsPcu&branch=master)](https://travis-ci.com/wind-c/comqtt/v2)
4+
[![Build Status](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml/badge.svg)](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml)
55
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/wind-c/comqtt/issues)
66
[![codecov](https://codecov.io/gh/wind-c/comqtt/branch/master/graph/badge.svg?token=6vBUgYVaVB)](https://codecov.io/gh/wind-c/comqtt/v2)
77
[![GoDoc](https://godoc.org/github.com/wind-c/comqtt?status.svg)](https://pkg.go.dev/github.com/wind-c/comqtt/v2)

docker-compose.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,16 @@ services:
99
- "3306:3306"
1010
command: --character-set-server=utf8 --collation-server=utf8_general_ci
1111
volumes:
12-
- ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql
12+
- ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql
13+
14+
postgresql:
15+
image: postgres:16
16+
container_name: postgresql
17+
environment:
18+
POSTGRES_USER: postgres
19+
POSTGRES_PASSWORD: 12345678
20+
POSTGRES_DB: comqtt
21+
ports:
22+
- "5432:5432"
23+
volumes:
24+
- ./plugin/auth/postgresql/testdata/init:/docker-entrypoint-initdb.d

plugin/auth/postgresql/postgresql_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/wind-c/comqtt/v2/plugin"
1414
)
1515

16-
const path = "./conf.yml"
16+
const path = "./testdata/conf.yml"
1717

1818
var (
1919
// Currently, the input is directed to /dev/null. If you need to
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
BEGIN;
2+
CREATE TABLE auth (
3+
id serial PRIMARY KEY,
4+
username TEXT NOT NULL UNIQUE,
5+
password TEXT NOT NULL,
6+
allow smallint DEFAULT 1 NOT NULL,
7+
created timestamp with time zone DEFAULT NOW(),
8+
updated timestamp
9+
);
10+
11+
CREATE TABLE acl(
12+
id serial PRIMARY KEY,
13+
username TEXT NOT NULL,
14+
topic TEXT NOT NULL,
15+
access smallint DEFAULT 3 NOT NULL,
16+
created timestamp with time zone DEFAULT NOW(),
17+
updated timestamp
18+
);
19+
CREATE INDEX acl_username_idx ON acl(username);
20+
21+
INSERT INTO auth (username, password, allow) VALUES ('zhangsan', '321654', 1);
22+
INSERT INTO acl (username, topic, access) VALUES ('zhangsan', 'topictest/1', 2);
23+
24+
COMMIT;

0 commit comments

Comments
 (0)