add more tests
This commit is contained in:
parent
74add408e6
commit
4a528fe85a
9 changed files with 266 additions and 55 deletions
|
@ -17,17 +17,22 @@ func main() {
|
|||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
playerStore := store.NewPlayerStore(db)
|
||||
vehicleStore := store.NewVehicleStore(db)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer cancel()
|
||||
|
||||
run(ctx, playerStore, vehicleStore)
|
||||
}
|
||||
|
||||
func run(ctx context.Context, ps store.IPlayerStore, vs store.IVehicleStore) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
playerStore := store.NewPlayerStore(db)
|
||||
i, err := playerStore.Prune(ctx)
|
||||
i, err := ps.Prune(ctx)
|
||||
if err != nil {
|
||||
log.Println("pruner: playerStore.Prune failed")
|
||||
}
|
||||
|
@ -38,9 +43,7 @@ func main() {
|
|||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
vehicleStore := store.NewVehicleStore(db)
|
||||
i, err := vehicleStore.Prune(ctx)
|
||||
i, err := vs.Prune(ctx)
|
||||
if err != nil {
|
||||
log.Println("pruner: vehicleStore.Prune failed")
|
||||
}
|
||||
|
|
22
cmd/pruner/pruner_test.go
Normal file
22
cmd/pruner/pruner_test.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/genudine/saerro-go/store/storemock"
|
||||
)
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
ps := new(storemock.MockPlayerStore)
|
||||
vs := new(storemock.MockVehicleStore)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer cancel()
|
||||
|
||||
ps.On("Prune", ctx).Return(30, nil)
|
||||
vs.On("Prune", ctx).Return(30, nil)
|
||||
|
||||
run(ctx, ps, vs)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue