package mocks

import (
	"github.com/fiskerinc/cloud-services/pkg/common"
	"github.com/fiskerinc/cloud-services/pkg/db/queries"

	"github.com/go-pg/pg/v10/orm"
)

type MockSubscriptionConfigurations struct {
	ListResult []common.SubscriptionConfiguration
	DBMockHelper
}

func (m *MockSubscriptionConfigurations) SetListResp(list interface{}) {
	if list != nil {
		m.ListResult = list.([]common.SubscriptionConfiguration)
	} else {
		m.ListResult = nil
	}
}

func (m *MockSubscriptionConfigurations) SetLoadResp(item interface{}) {
	// no get result to set
}

func (m *MockSubscriptionConfigurations) Delete(model *common.SubscriptionConfiguration) (orm.Result, error) {
	m.LastFilter = model
	return m.ORMResponse, m.Error
}

func (m *MockSubscriptionConfigurations) Insert(model *common.SubscriptionConfiguration) (orm.Result, error) {
	m.LastFilter = model
	return m.ORMResponse, m.Error
}

func (m *MockSubscriptionConfigurations) Update(model *common.SubscriptionConfiguration) (orm.Result, error) {
	m.LastFilter = model
	return m.ORMResponse, m.Error
}

func (m *MockSubscriptionConfigurations) Count(filter *common.SubscriptionConfiguration) (int, error) {
	m.LastFilter = filter
	return len(m.ListResult), m.Error
}

func (m *MockSubscriptionConfigurations) Select(filter *common.SubscriptionConfiguration, paging *queries.PageQueryOptions) ([]common.SubscriptionConfiguration, error) {
	m.LastFilter = filter
	m.LastPaging = paging

	return m.ListResult, m.Error
}
