add more tests

This commit is contained in:
41666 2024-10-28 19:53:57 -07:00
parent 74add408e6
commit 4a528fe85a
9 changed files with 266 additions and 55 deletions

View file

@ -0,0 +1,45 @@
package storemock
import (
"context"
"database/sql"
"github.com/genudine/saerro-go/types"
"github.com/stretchr/testify/mock"
)
type MockVehicleStore struct {
mock.Mock
DB *sql.DB
RanMigration bool
}
func (m *MockVehicleStore) IsMigrated(ctx context.Context) bool {
args := m.Called(ctx)
return args.Bool(0)
}
func (m *MockVehicleStore) RunMigration(ctx context.Context, force bool) {
m.Called(ctx, force)
}
func (m *MockVehicleStore) Insert(ctx context.Context, vehicle *types.Vehicle) error {
args := m.Called(ctx, vehicle)
return args.Error(0)
}
func (m *MockVehicleStore) GetOne(ctx context.Context, id string) (*types.Vehicle, error) {
args := m.Called(ctx, id)
if args.Get(0) == nil {
return nil, args.Error(1)
}
return args.Get(0).(*types.Vehicle), args.Error(1)
}
func (m *MockVehicleStore) Prune(ctx context.Context) (int64, error) {
args := m.Called(ctx)
return int64(args.Int(0)), args.Error(1)
}

View file

@ -11,6 +11,14 @@ import (
"github.com/avast/retry-go"
)
type IVehicleStore interface {
IsMigrated(context.Context) bool
RunMigration(context.Context, bool)
Insert(context.Context, *types.Vehicle) error
GetOne(context.Context, string) (*types.Vehicle, error)
Prune(context.Context) (int64, error)
}
type VehicleStore struct {
DB *sql.DB