Skip to content

Commit

Permalink
infra: fix circullar imports
Browse files Browse the repository at this point in the history
Signed-off-by: Arnav Gupta <championswimmer@gmail.com>
  • Loading branch information
championswimmer committed Feb 9, 2024
1 parent 674d9a4 commit ad6b7f0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/controllers/urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package controllers
import (
"github.com/stretchr/testify/assert"
"onepixel_backend/src/utils/applogger"
_ "onepixel_backend/tests"
_ "onepixel_backend/tests/providers"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/stretchr/testify/assert"
"gorm.io/gorm"
"onepixel_backend/src/utils/applogger"
_ "onepixel_backend/tests"
_ "onepixel_backend/tests/providers"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion src/security/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package security
import (
"onepixel_backend/src/db/models"
"onepixel_backend/src/utils/applogger"
_ "onepixel_backend/tests"
_ "onepixel_backend/tests/providers"
"testing"

"github.com/stretchr/testify/assert"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package tests
package providers

import (
"github.com/c0deltin/duckdb-driver/duckdb"
"github.com/samber/lo"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"onepixel_backend/src/db"
"onepixel_backend/src/utils/applogger"
)

func init() {
db.InjectDBProvider("sqlite", ProvideSqliteDB)
db.InjectDBProvider("duckdb", ProvideDuckDB)

}

func ProvideSqliteDB(dbUrl string, config *gorm.Config) *gorm.DB {
applogger.Warn("Test: Using sqlite db")
return lo.Must(gorm.Open(sqlite.Open(dbUrl), config))
Expand Down
4 changes: 1 addition & 3 deletions tests/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import (
"io"
"net/http/httptest"
"onepixel_backend/src/config"
"onepixel_backend/src/db"
"onepixel_backend/src/dtos"
"onepixel_backend/src/server"
_ "onepixel_backend/tests/providers"
"testing"
)

var App *fiber.App
var MainApp *fiber.App

func init() {
db.InjectDBProvider("sqlite", ProvideSqliteDB)
db.InjectDBProvider("duckdb", ProvideDuckDB)
App = server.CreateAdminApp()
MainApp = server.CreateMainApp()
}
Expand Down

0 comments on commit ad6b7f0

Please sign in to comment.