-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from scrabblett/feature/functional-tests
add new handlers, functional tests
- Loading branch information
Showing
42 changed files
with
1,298 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
POSTGRES_USER=postgres | ||
POSTGRES_PASSWORD=12345 | ||
POSTGRES_DB=books_library | ||
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?sslmode=disable | ||
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable | ||
HTTP_SERVER_ADDRESS=localhost | ||
HTTP_SERVER_PORT=8080 | ||
HTTP_SERVER_TIMEOUT=5s | ||
HTTP_SERVER_TIMEOUT=15s | ||
HTTP_SERVER_IDLE_TIMEOUT=60s | ||
PGDATA=/data/postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.vscode | ||
.idea | ||
*.log | ||
*.db | ||
*.db | ||
cover.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
FROM golang:latest | ||
LABEL authors="Dmitry Sagan" | ||
LABEL description="Simple api written in Go. For any questions: telegram @quryy" | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
RUN go install github.com/pressly/goose/v3/cmd/goose@latest | ||
RUN go build ./cmd/app/main.go | ||
# Install linter | ||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2 | ||
|
||
# Run makefile | ||
RUN make all | ||
|
||
# Run backend | ||
CMD ["go run ./cmd/app/main.go"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
all: deps vet fmt tools lint deps mocks test test_coverage | ||
|
||
deps: | ||
@echo Install dependencies | ||
go mod tidy | ||
go mod download | ||
|
||
vet: | ||
go vet ./... | ||
|
||
fmt: | ||
@echo "$(OK_COLOR)Check fmt$(NO_COLOR)" | ||
@echo "FIXME go fmt does not format imports, should be fixed" | ||
@go fmt ./... | ||
|
||
tools: | ||
go install golang.org/x/tools/cmd/goimports@latest | ||
go install github.com/vektra/mockery/[email protected] | ||
go get golang.org/x/tools/cmd/cover | ||
|
||
lint: | ||
golangci-lint run -enable-all | ||
|
||
mocks: | ||
go generate ./... | ||
|
||
test: | ||
go test ./... -coverprofile cover.out | ||
|
||
test_coverage: | ||
go tool cover -html cover.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
package main | ||
|
||
import "simple-golang-api/internal/app" | ||
import ( | ||
"simple-golang-api/internal/app" | ||
) | ||
|
||
func main() { | ||
app.Run() | ||
|
||
//toDo: cache requests, functional tests | ||
//toDo: add pagination for books methods in handler | ||
//toDo: work with context | ||
//toDO: refactor unit-tests, mocks for integration tests | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.