Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cubny committed Feb 12, 2024
1 parent 6feb521 commit 7dd07d0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ func main() {

ctx, cancel := context.WithCancel(context.Background())

app, err := internal.Init(ctx)
runMigration := true
app, err := internal.Init(ctx, runMigration)
if err != nil {
log.Fatalf("failed to initiate App, %v", err)
}
Expand Down
6 changes: 4 additions & 2 deletions internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ type App struct {
//go:embed infra/sqlite/migrations/*.sql
var embedMigrations embed.FS

func Init(ctx context.Context) (*App, error) {
func Init(ctx context.Context, runMigration bool) (*App, error) {
a := &App{ctx: ctx}
a.initConfig()
a.initSqlClient()
a.migrate()
if runMigration {
a.migrate()
}
a.initRepo()
a.initServices()
a.initScheduler()
Expand Down
3 changes: 2 additions & 1 deletion internal/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
)

func TestWithContext(t *testing.T) {
app, err := Init(context.Background())
runMigration := false
app, err := Init(context.Background(), runMigration)
require.NoError(t, err)
assert.Equal(t, context.Background(), app.ctx)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ type Config struct {
}

type DB struct {
Path string `env:"DB_PATH"`
Path string `env:"DB_PATH, default=data/agg.db"`
}

type HTTP struct {
Port int `env:"HTTP_PORT"`
Port int `env:"HTTP_PORT, default=3000"`
}

// New constructs the config.
Expand Down

0 comments on commit 7dd07d0

Please sign in to comment.