Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
53
pkg/db/queries/mocks/certificates.go
Normal file
53
pkg/db/queries/mocks/certificates.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"github.com/go-pg/pg/v10/orm"
|
||||
|
||||
"fiskerinc.com/modules/common"
|
||||
"fiskerinc.com/modules/validator"
|
||||
)
|
||||
|
||||
// CarUpdate query methods
|
||||
type MockCertificates struct {
|
||||
DBMockHelper
|
||||
MockListResponse []common.Certificate
|
||||
MockCertificate *common.Certificate
|
||||
}
|
||||
|
||||
func (c *MockCertificates) Insert(cert *common.Certificate) (orm.Result, error) {
|
||||
return c.ORMResponse, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) Update(cert *common.Certificate) (orm.Result, error) {
|
||||
if cert.SerialNumber == "" {
|
||||
return nil, &validator.FieldError{
|
||||
ErrorMsg: "Serial number required",
|
||||
}
|
||||
}
|
||||
return c.ORMResponse, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) Remove(cert *common.Certificate) (orm.Result, error) {
|
||||
if cert.SerialNumber == "" {
|
||||
return nil, &validator.FieldError{
|
||||
ErrorMsg: "Serial number required",
|
||||
}
|
||||
}
|
||||
return c.ORMResponse, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) SelectByCommonName(cn string) ([]common.Certificate, error) {
|
||||
return c.MockListResponse, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) SelectBySerial(serial string) (*common.Certificate, error) {
|
||||
return c.MockCertificate, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) SelectMostRecent(cn string, certType string) (*common.Certificate, error) {
|
||||
return c.MockCertificate, c.Error
|
||||
}
|
||||
|
||||
func (c *MockCertificates) SelectMostRecents(cn string, certTypes []string) ([]common.Certificate, error) {
|
||||
return c.MockListResponse, c.Error
|
||||
}
|
||||
Reference in New Issue
Block a user