Skip to content

Commit

Permalink
Merge pull request #100 from ohkinozomu/postgres-docker-compose
Browse files Browse the repository at this point in the history
Enable PostgreSQL tests in GitHub Actions
  • Loading branch information
wind-c authored Jul 29, 2024
2 parents 66f830c + ea53432 commit 8b8aed3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<p align="center">

[![Build Status](https://travis-ci.com/wind-c/comqtt.svg?token=59nqixhtefy2iQRwsPcu&branch=master)](https://travis-ci.com/wind-c/comqtt/v2)
[![Build Status](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml/badge.svg)](https://github.com/wind-c/comqtt/actions/workflows/runtests.yaml)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/wind-c/comqtt/issues)
[![codecov](https://codecov.io/gh/wind-c/comqtt/branch/master/graph/badge.svg?token=6vBUgYVaVB)](https://codecov.io/gh/wind-c/comqtt/v2)
[![GoDoc](https://godoc.org/github.com/wind-c/comqtt?status.svg)](https://pkg.go.dev/github.com/wind-c/comqtt/v2)
Expand Down
14 changes: 13 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,16 @@ services:
- "3306:3306"
command: --character-set-server=utf8 --collation-server=utf8_general_ci
volumes:
- ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./plugin/auth/mysql/testdata/init.sql:/docker-entrypoint-initdb.d/init.sql

postgresql:
image: postgres:16
container_name: postgresql
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 12345678
POSTGRES_DB: comqtt
ports:
- "5432:5432"
volumes:
- ./plugin/auth/postgresql/testdata/init:/docker-entrypoint-initdb.d
2 changes: 1 addition & 1 deletion plugin/auth/postgresql/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/wind-c/comqtt/v2/plugin"
)

const path = "./conf.yml"
const path = "./testdata/conf.yml"

var (
// Currently, the input is directed to /dev/null. If you need to
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions plugin/auth/postgresql/testdata/init/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BEGIN;
CREATE TABLE auth (
id serial PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
allow smallint DEFAULT 1 NOT NULL,
created timestamp with time zone DEFAULT NOW(),
updated timestamp
);

CREATE TABLE acl(
id serial PRIMARY KEY,
username TEXT NOT NULL,
topic TEXT NOT NULL,
access smallint DEFAULT 3 NOT NULL,
created timestamp with time zone DEFAULT NOW(),
updated timestamp
);
CREATE INDEX acl_username_idx ON acl(username);

INSERT INTO auth (username, password, allow) VALUES ('zhangsan', '321654', 1);
INSERT INTO acl (username, topic, access) VALUES ('zhangsan', 'topictest/1', 2);

COMMIT;

0 comments on commit 8b8aed3

Please sign in to comment.