-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (52 loc) · 2.28 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#############################
# test
############################
test:
GO111MODULE=on go vet ./...
GO111MODULE=on go test -i .
GO111MODULE=on go test -v -short -failfast -race -count=1 \
-coverpkg=./... \
-coverprofile coverage.txt \
-covermode=atomic \
./...
GO111MODULE=on go tool cover -html=coverage.txt -o coverage.html
@echo "Coverage: file://$(PWD)/coverage.html"
integrations:
GO111MODULE=on go test -i .
GO111MODULE=on go test -v ./...
#############################
# build, migrateand run
############################
build:
go build -mod=vendor -o bin/cart github.com/cubny/cart/cmd/...
migrate:
./bin/cart -data ./data/cart.db -migrate
run:
./bin/cart -data ./data/cart.db
firstrun: build migrate run
#############################
# build, migrateand run with docker
############################
docker-build:
docker build -t cubny/cart .
docker-migrate:
docker run --name cart -v `pwd`/data:/app/data -it --rm cubny/cart app/bin/cart -data /app/data/cart.db -migrate
docker-run:
docker run --name cart -p 8080:8080 -p 8081:8081 -v `pwd`/data:/app/data -it --rm cubny/cart app/bin/cart -data /app/data/cart.db
docker-firstrun: docker-build docker-migrate docker-run
#############################
# handy tools to test the api
############################
addcart:
curl -i -XPOST http://localhost:8080/carts -H "Authorisation: Key abcdef123456"
additem:
curl -i -XPOST http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456" -d '{"product_id":1, "quantity":1, "price":100.00}'
removeitem:
curl -i -XDELETE http://localhost:8080/items/1 -H "Authorisation: Key abcdef123456"
add5items:
curl -i -XPOST http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456" -d '{"product_id":2, "quantity":1, "price":10.00}'
curl -i -XPOST http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456" -d '{"product_id":3, "quantity":3, "price":12.00}'
curl -i -XPOST http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456" -d '{"product_id":4, "quantity":1, "price":2.50}'
curl -i -XPOST http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456" -d '{"product_id":5, "quantity":1, "price":0.99}'
emptycart:
curl -i -XDELETE http://localhost:8080/carts/1/items -H "Authorisation: Key abcdef123456"