Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ulascansenturk committed Aug 17, 2024
1 parent ddabd10 commit 39d3e50
Show file tree
Hide file tree
Showing 24 changed files with 1,254 additions and 88 deletions.
45 changes: 45 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
with-expecter: false
packages:
ulascansenturk/service/internal/accounts:
interfaces:
Repository:
config:
dir: internal/accounts/mocks
exported: true
outpkg: mocks
structname: SQLRepository
disable-version-string: true
Service:
config:
dir: internal/accounts/mocks
exported: true
outpkg: mocks
structname: AccountServiceImpl
disable-version-string: true
ulascansenturk/service/internal/transactions:
interfaces:
FinderOrCreator:
config:
dir: internal/transactions/mocks
exported: true
outpkg: mocks
structname: FinderOrCreatorService
disable-version-string: true
Service:
config:
dir: internal/transactions/mocks
exported: true
outpkg: mocks
structname: TransactionServiceImpl
disable-version-string: true
ulascansenturk/service/internal/helpers:
interfaces:
TimeProvider:
config:
dir: internal/helpers/mocks
exported: true
outpkg: mocks
structname: RealTimeProvider
disable-version-string: true




4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/docker/library/golang:1.22.5-alpine3.20 AS base
FROM public.ecr.aws/docker/library/golang:1.22.5-alpine3.20 AS basedockerf

ARG GITHUB_USER
ARG GITHUB_PASSWORD
Expand Down Expand Up @@ -27,7 +27,6 @@ COPY Makefile Makefile
COPY cmd cmd
COPY db db
COPY internal internal
COPY pkg pkg
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

Expand All @@ -38,7 +37,6 @@ COPY .golangci.yml .

# Required for pg_dump
RUN apk update && apk add --no-cache postgresql-client
RUN apk add --no-cache netcat-openbsd
RUN apk update && apk add --no-cache gcc libc-dev bash make curl

RUN curl -sSf https://temporal.download/cli.sh | sh
Expand Down
11 changes: 11 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package main

import (
"context"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"
"github.com/samber/do"
"go.temporal.io/sdk/worker"
"net/http"
"ulascansenturk/service/cmd/utils"
"ulascansenturk/service/internal/api"

"ulascansenturk/service/internal/appbase"
)
Expand Down Expand Up @@ -57,3 +59,12 @@ func main() {
}
<-ctx.Done()
}

func buildRouter(app *appbase.AppBase) *chi.Mux {
mux := do.MustInvokeNamed[*chi.Mux](app.Injector, appbase.InjectorApplicationRouter)
routes := do.MustInvoke[*api.Routes](app.Injector)

api.InitRoutes(mux, routes)

return mux
}
18 changes: 0 additions & 18 deletions cmd/server/router.go

This file was deleted.

14 changes: 5 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ services:
COMPOSE_DOCKER_CLI_BUILD: 1
TEMPORAL_ADDRESS: temporal:7233
TC_HOST: host.docker.internal
env_file:
- .env.docker
volumes:
- .:/app
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "3000:3000"
depends_on:
database:
condition: service_healthy
redis:
condition: service_healthy
- database
- temporal
- redis
networks:
- app-network

Expand All @@ -37,11 +38,6 @@ services:
ports:
- "7233:7233"
- "8233:8233"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8233/health"]
interval: 5s
timeout: 5s
retries: 5
networks:
- app-network

Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ echo "Running database migrations..."

# Start the main application
echo "Starting the application..."
exec go run ./cmd/server
exec go run cmd/server/main.go
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.2 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7OputlJIzU=
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down Expand Up @@ -127,6 +129,7 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down
Loading

0 comments on commit 39d3e50

Please sign in to comment.