Skip to content

Commit

Permalink
fix: more robust test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayanami1314 committed Aug 9, 2024
1 parent 50b4eed commit b035175
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions handler/trainingplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"gorm.io/gorm"
"jcourse_go/dal"
"net/http"
Expand Down Expand Up @@ -37,10 +38,10 @@ func prettyJsonLog(w *httptest.ResponseRecorder) {
}
func baseConfig() (*httptest.ResponseRecorder, *gin.Engine) {
gin.SetMode(gin.TestMode)
err := dal.InitSqliteDBTest("../gorm.db")
if err != nil {
panic(err)
}
os.Setenv("ROOT_DIR", "/home/ayanmi/code/jcourse/jcourse_go")
rootDir := os.Getenv("ROOT_DIR")
_ = godotenv.Load(rootDir + "/.env")
dal.InitDBClient()
w := httptest.NewRecorder()
r := gin.Default()
return w, r
Expand Down

0 comments on commit b035175

Please sign in to comment.