review test database and fix config restserver
This commit is contained in:
1 parent
d379223517
commit
f5a652c13b
10 files changed
+17
-8
No files matched your search
@@ -12,7 +12,7 @@ var (
|
||||
func TestMain(m *testing.M) {
|
||||
database := os.Getenv("DATABASE_URL")
|
||||
if database == "" {
|
||||
database = "host=localhost user=admin password=root dbname=postgres sslmode=disable"
|
||||
database = "host=localhost user=test password=test dbname=test sslmode=disable"
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
|
||||
@@ -5,5 +5,7 @@ type ConfigBD struct {
|
||||
}
|
||||
|
||||
func NewConfig() *ConfigBD {
|
||||
return &ConfigBD{}
|
||||
return &ConfigBD{
|
||||
BaseUrlBd: "host=localhost user=admin password=root dbname=postgres sslmode=disable",
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func TestFilmRepo_Create(t *testing.T) {
|
||||
|
||||
s, teardown := bd.Testdb(t, "host=localhost user=admin password=root dbname=postgres sslmode=disable")
|
||||
s, teardown := bd.Testdb(t, "host=localhost user=test password=test dbname=test sslmode=disable")
|
||||
defer teardown("films")
|
||||
u, err := s.Films().Create(&model.Films{
|
||||
Id: 11,
|
||||
|
||||
@@ -12,7 +12,7 @@ func Testdb(t *testing.T, databaseurl string) (*Bd, func(...string)) {
|
||||
config := NewConfig()
|
||||
config.BaseUrlBd = databaseurl
|
||||
s := New(config)
|
||||
|
||||
fmt.Println(config.BaseUrlBd)
|
||||
if err := s.Open(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user