porter_app.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package test
  2. import (
  3. "context"
  4. "errors"
  5. "strings"
  6. "github.com/porter-dev/porter/internal/models"
  7. "github.com/porter-dev/porter/internal/repository"
  8. )
  9. type PorterAppRepository struct {
  10. canQuery bool
  11. failingMethods string
  12. }
  13. func NewPorterAppRepository(canQuery bool, failingMethods ...string) repository.PorterAppRepository {
  14. return &PorterAppRepository{canQuery, strings.Join(failingMethods, ",")}
  15. }
  16. func (repo *PorterAppRepository) ReadPorterAppByName(clusterID uint, name string) (*models.PorterApp, error) {
  17. return nil, errors.New("cannot write database")
  18. }
  19. // ReadPorterAppsByProjectIDAndName is a test method that is not implemented
  20. func (repo *PorterAppRepository) ReadPorterAppsByProjectIDAndName(projectID uint, name string) ([]*models.PorterApp, error) {
  21. return nil, errors.New("cannot write database")
  22. }
  23. func (repo *PorterAppRepository) CreatePorterApp(app *models.PorterApp) (*models.PorterApp, error) {
  24. return nil, errors.New("cannot write database")
  25. }
  26. func (repo *PorterAppRepository) UpdatePorterApp(app *models.PorterApp) (*models.PorterApp, error) {
  27. return nil, errors.New("cannot write database")
  28. }
  29. // ListPorterAppByClusterID is a test method that is not implemented
  30. func (repo *PorterAppRepository) ListPorterAppByClusterID(clusterID uint) ([]*models.PorterApp, error) {
  31. return nil, errors.New("cannot write database")
  32. }
  33. func (repo *PorterAppRepository) DeletePorterApp(app *models.PorterApp) (*models.PorterApp, error) {
  34. return nil, errors.New("cannot write database")
  35. }
  36. // ReadPorterAppByID is a test method that is not implemented
  37. func (repo *PorterAppRepository) ReadPorterAppByID(ctx context.Context, id uint) (*models.PorterApp, error) {
  38. return nil, errors.New("cannot read database")
  39. }