package mocks

import (
	"fmt"

	"github.com/fiskerinc/cloud-services/pkg/db/queries"
	"github.com/go-pg/pg/v10/orm"
)

type DBMockHelperInterface interface {
	GetFilter() fmt.Stringer
	GetPaging() *queries.PageQueryOptions
	SetListResp(list interface{})
	SetLoadResp(item interface{})
	SetErr(error)
	SetDriverError(error)
}

type DBMockHelper struct {
	SelectOrInsertResult bool
	ORMResponse          orm.Result
	Error                error
	DriverError          error
	LastFilter           fmt.Stringer
	LastPaging           *queries.PageQueryOptions
}

func (m *DBMockHelper) GetFilter() fmt.Stringer {
	return m.LastFilter
}

func (m *DBMockHelper) GetPaging() *queries.PageQueryOptions {
	return m.LastPaging
}

func (m *DBMockHelper) SetListResp(list interface{}) {
	// fmt.Printf("override SetListResp() in %s\n", reflect.TypeOf(list))
}

func (m *DBMockHelper) SetLoadResp(item interface{}) {
	// fmt.Printf("override SetLoadResp() in %s\n", reflect.TypeOf(item))
}

func (m *DBMockHelper) SetErr(err error) {
	m.Error = err
}

func (up *DBMockHelper) SetDriverError(err error) {
	up.DriverError = err
}
