mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-05 09:10:26 +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"
|
"testing"
|
||||||
|
|
||||||
"github.com/hay-kot/homebox/backend/ent"
|
"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/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"
|
"github.com/hay-kot/homebox/backend/internal/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -39,12 +40,17 @@ func userPool() func() {
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// Set Handler Vars
|
// Set Handler Vars
|
||||||
repos, closeDb := mocks.GetEntRepos()
|
c, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1")
|
||||||
mockHandler.svc = mocks.GetMockServices(repos)
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
defer func() {
|
if err := c.Schema.Create(context.Background()); err != nil {
|
||||||
_ = closeDb()
|
panic(err)
|
||||||
}()
|
}
|
||||||
|
|
||||||
|
repos := repo.EntAllRepos(c, "/tmp/homebox")
|
||||||
|
mockHandler.svc = services.NewServices(repos)
|
||||||
|
|
||||||
purge := userPool()
|
purge := userPool()
|
||||||
defer purge()
|
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