forked from DATA-DOG/go-txdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (30 loc) · 804 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
define DB_SQL
CREATE TABLE users (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
username VARCHAR(32) NOT NULL,
email VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
UNIQUE INDEX uniq_email (email)
) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
INSERT INTO users(username, email) VALUES
("gopher", "[email protected]"),
("john", "[email protected]"),
("jane", "[email protected]");
endef
export DB_SQL
SQL := "$$DB_SQL"
lint:
@go fmt ./...
@golint ./...
@go vet ./...
test: db
@go test
db:
@mysql -u root -e 'DROP DATABASE IF EXISTS `txdb_test`'
@mysql -u root -e 'CREATE DATABASE IF NOT EXISTS `txdb_test`'
@mysql -u root txdb_test -e $(SQL)
cover: db
go test -race -coverprofile=coverage.txt
go tool cover -html=coverage.txt
rm coverage.txt
.PHONY: test db lint cover