Skip to content

Commit

Permalink
logical redundacies refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley committed Feb 4, 2024
1 parent 727e858 commit accd5c2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ jobs:
docker exec $CONTAINER_ID cat /var/lib/postgresql/data/postgresql.conf | grep max_connections
- name: Restart PostgreSQL Container
run: docker restart $(docker ps --filter "publish=5432" --format "{{.ID}}")
- name: Migrate DB
run: cd ./backend/src && go run main.go --only-migrate
- name: Run Tests with Coverage
run: cd ./backend/ && go test -bench=. -benchmem -race -coverprofile=coverage.txt ./...
- name: Print Coverage
Expand Down
12 changes: 1 addition & 11 deletions backend/src/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"flag"
"fmt"
"path/filepath"

Expand All @@ -19,12 +18,7 @@ import (
// @host 127.0.0.1:8080
// @BasePath /api/v1
func main() {
onlyMigrate := flag.Bool("only-migrate", false, "Specify if you want to only perform the database migration")
configPath := flag.String("config", filepath.Join("..", "..", "config"), "Specify the path to the config directory")

flag.Parse()

config, err := config.GetConfiguration(*configPath)
config, err := config.GetConfiguration(filepath.Join("..", "..", "config"))
if err != nil {
panic(fmt.Sprintf("Error getting configuration: %s", err.Error()))
}
Expand All @@ -34,10 +28,6 @@ func main() {
panic(fmt.Sprintf("Error configuring database: %s", err.Error()))
}

if *onlyMigrate {
return
}

err = database.ConnPooling(db)
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/api/helpers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ var (
once sync.Once
)

func RootConn(dbConfig config.DatabaseSettings) {
func RootConn(dbSettings config.DatabaseSettings) {
once.Do(func() {
var err error
rootConn, err = database.EstablishConn(dbConfig.WithoutDb())
rootConn, err = database.EstablishConn(dbSettings.WithoutDb())
if err != nil {
panic(err)
}
Expand Down
File renamed without changes.

0 comments on commit accd5c2

Please sign in to comment.