forked from upper/db
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (31 loc) · 937 Bytes
/
Makefile
File metadata and controls
40 lines (31 loc) · 937 Bytes
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
39
40
SHELL := bash
DB_HOST ?= 127.0.0.1
DB_PORT ?= 3306
DB_USERNAME ?= upperio_tests
DB_PASSWORD ?= upperio_secret
DB_NAME ?= upperio_tests
TEST_FLAGS ?=
export DB_HOST
export DB_NAME
export DB_PASSWORD
export DB_PORT
export DB_USERNAME
build:
go build && go install
require-client:
@if [ -z "$$(which mysql)" ]; then \
echo 'Missing "mysql" command. Please install the MySQL client and try again.' && \
exit 1; \
fi
generate:
go generate && \
go get -d -t -v ./...
reset-db: require-client
SQL="" && \
SQL+="DROP DATABASE IF EXISTS $(DB_NAME);" && \
SQL+="CREATE DATABASE $(DB_NAME);" && \
SQL+="GRANT ALL PRIVILEGES ON $(DB_NAME).* TO $(DB_USERNAME) IDENTIFIED BY '$(DB_PASSWORD)';" && \
mysql -uroot -h"$(DB_HOST)" -P$(DB_PORT) <<< $$SQL
test: reset-db generate
#go test -tags generated -v -race # race: limit on 8192 simultaneously alive goroutines is exceeded, dying
go test -tags generated -v $(TEST_FLAGS)