Skip to content

Bringing it to life #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Ci Test
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Init db
run: |
./run.sh startdb
sleep 6
./run.sh initdb products_db

- name: Running tests
run: |
go test ./app/

- name: Cleaning
run: |
./run.sh stopdb
./run.sh cleanup
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (app *RESTApp) Initialize(user, password, dbname string) {
if err != nil {
log.Fatal(err)
}
app.CreateTableIfNotExists()

app.Router = mux.NewRouter()
app.initializeRoutes()
Expand Down
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

startdb() {
echo "Starting postgres database"
docker-compose up -d
docker compose up -d
echo "Started."
}

Expand All @@ -20,7 +20,7 @@ dblogs() {
initdb() {
if [[ -n "$1" ]]; then
echo "Initializing database with name: $1"
docker exec -it go_postgres psql -U postgres -c "create database $1" # db-name
docker exec -i go_postgres psql -U postgres -c "create database $1" # db-name
else
echo "No database name provided, use initdb <database-name>"
fi
Expand Down