63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package mocks
|
|
|
|
import (
|
|
"fiskerinc.com/modules/common"
|
|
"fiskerinc.com/modules/db/queries"
|
|
"github.com/go-pg/pg/v10/orm"
|
|
)
|
|
|
|
type MockAPITokens struct {
|
|
ListResult []common.APIToken
|
|
GetResult *common.APIToken
|
|
DBMockHelper
|
|
}
|
|
|
|
func (m *MockAPITokens) SetListResp(list interface{}) {
|
|
if list != nil {
|
|
m.ListResult = list.([]common.APIToken)
|
|
} else {
|
|
m.ListResult = nil
|
|
}
|
|
}
|
|
|
|
func (m *MockAPITokens) SetLoadResp(item interface{}) {
|
|
if item != nil {
|
|
m.GetResult = item.(*common.APIToken)
|
|
} else {
|
|
m.GetResult = nil
|
|
}
|
|
}
|
|
|
|
func (m *MockAPITokens) Delete(token string) (orm.Result, error) {
|
|
m.LastFilter = &common.APIToken{Token: token}
|
|
return m.ORMResponse, m.Error
|
|
}
|
|
|
|
func (m *MockAPITokens) Insert(keyValue common.APIToken) (orm.Result, error) {
|
|
return m.ORMResponse, m.Error
|
|
}
|
|
|
|
func (m *MockAPITokens) Get(token string) (*common.APIToken, error) {
|
|
m.LastFilter = &common.APIToken{Token: token}
|
|
return m.GetResult, m.Error
|
|
}
|
|
|
|
func (m *MockAPITokens) Update(keyValue *common.APIToken) (orm.Result, error) {
|
|
return m.ORMResponse, m.Error
|
|
}
|
|
|
|
func (m *MockAPITokens) Select(filter *common.APIToken, paging *queries.PageQueryOptions) ([]common.APIToken, error) {
|
|
m.LastFilter = filter
|
|
m.LastPaging = paging
|
|
|
|
return m.ListResult, m.Error
|
|
}
|
|
|
|
func (m *MockAPITokens) Count(apitoken *common.APIToken) (int, error) {
|
|
if m.Error != nil {
|
|
return 0, m.Error
|
|
}
|
|
|
|
return len(m.ListResult), nil
|
|
}
|