Skip to content

Commit

Permalink
fix(test): go tried to connect to postgres but it sucked
Browse files Browse the repository at this point in the history
  • Loading branch information
oddyamill committed Aug 28, 2024
1 parent 92cb508 commit b56a029
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ jobs:
go-version: "1.22.6"
- name: Test
run: go test -v ./...
env:
TESTING: true
6 changes: 6 additions & 0 deletions internal/users/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/kiasuo/bot/internal/helpers"
_ "github.com/lib/pq"
"log"
"os"
)

type UserState int
Expand All @@ -31,6 +32,11 @@ type User struct {
var db *sql.DB

func init() {
// todo
if os.Getenv("TESTING") == "true" {
return
}

uri := "user=" + helpers.GetEnv("POSTGRES_USER") +
" dbname=" + helpers.GetEnv("POSTGRES_DB") +
" password=" + helpers.GetEnv("POSTGRES_PASSWORD") +
Expand Down

0 comments on commit b56a029

Please sign in to comment.