add more tests
This commit is contained in:
parent
74add408e6
commit
4a528fe85a
9 changed files with 266 additions and 55 deletions
45
store/storemock/vehiclestore.go
Normal file
45
store/storemock/vehiclestore.go
Normal 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)
|
||||
}
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue