Files
cloud-services/pkg/db/queries/mocks/certificates.go

54 lines
1.4 KiB
Go

package mocks
import (
"github.com/go-pg/pg/v10/orm"
"github.com/fiskerinc/cloud-services/pkg/common"
"github.com/fiskerinc/cloud-services/pkg/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
}