Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
62
pkg/db/queries/mocks/apitokens.go
Normal file
62
pkg/db/queries/mocks/apitokens.go
Normal file
@@ -0,0 +1,62 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user