mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-03 08:10:28 +00:00
cleanup unnecessary mocks
This commit is contained in:
parent
2e82398e5c
commit
19e73378d3
3 changed files with 12 additions and 38 deletions
|
@ -5,8 +5,9 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/hay-kot/homebox/backend/ent"
|
||||
"github.com/hay-kot/homebox/backend/internal/mocks"
|
||||
"github.com/hay-kot/homebox/backend/internal/mocks/factories"
|
||||
"github.com/hay-kot/homebox/backend/internal/repo"
|
||||
"github.com/hay-kot/homebox/backend/internal/services"
|
||||
"github.com/hay-kot/homebox/backend/internal/types"
|
||||
)
|
||||
|
||||
|
@ -39,12 +40,17 @@ func userPool() func() {
|
|||
|
||||
func TestMain(m *testing.M) {
|
||||
// Set Handler Vars
|
||||
repos, closeDb := mocks.GetEntRepos()
|
||||
mockHandler.svc = mocks.GetMockServices(repos)
|
||||
c, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
_ = closeDb()
|
||||
}()
|
||||
if err := c.Schema.Create(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
repos := repo.EntAllRepos(c, "/tmp/homebox")
|
||||
mockHandler.svc = services.NewServices(repos)
|
||||
|
||||
purge := userPool()
|
||||
defer purge()
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package mocks
|
||||
|
||||
import (
|
||||
"github.com/hay-kot/homebox/backend/internal/repo"
|
||||
"github.com/hay-kot/homebox/backend/internal/services"
|
||||
)
|
||||
|
||||
func GetMockServices(repos *repo.AllRepos) *services.AllServices {
|
||||
return services.NewServices(repos, "/tmp/homebox")
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/hay-kot/homebox/backend/ent"
|
||||
"github.com/hay-kot/homebox/backend/internal/repo"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func GetEntRepos() (*repo.AllRepos, func() error) {
|
||||
c, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := c.Schema.Create(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return repo.EntAllRepos(c), c.Close
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue