Justin Rhee 3 лет назад
Родитель
Сommit
17ad41878a

+ 1 - 1
internal/repository/porter_app.go

@@ -7,7 +7,7 @@ import (
 // PorterAppRepository represents the set of queries on the PorterApp model
 type PorterAppRepository interface {
 	CreatePorterApp(app *models.PorterApp) (*models.PorterApp, error)
-	ListPorterAppByClusterID(clusterID uint) ([]*models.PorterApp, error)
+	// ListPorterAppByClusterID(clusterID uint) ([]*models.PorterApp, error)
 	ReadPorterApp(clusterID uint, name string) (*models.PorterApp, error)
 	UpdatePorterApp(app *models.PorterApp) (*models.PorterApp, error)
 }

+ 31 - 0
internal/repository/test/porter_app.go

@@ -0,0 +1,31 @@
+package test
+
+import (
+	"errors"
+	"strings"
+
+	"github.com/porter-dev/porter/internal/models"
+	"github.com/porter-dev/porter/internal/repository"
+)
+
+type PorterAppRepository struct {
+	canQuery       bool
+	failingMethods string
+}
+
+func NewPorterAppRepository(canQuery bool, failingMethods ...string) repository.PorterAppRepository {
+	return &PorterAppRepository{canQuery, strings.Join(failingMethods, ",")}
+
+}
+
+func (repo *PorterAppRepository) CreatePorterApp(app *models.PorterApp) (*models.PorterApp, error) {
+	return nil, errors.New("cannot write database")
+}
+
+func (repo *PorterAppRepository) ReadPorterApp(clusterID uint, name string) (*models.PorterApp, error) {
+	return nil, errors.New("cannot write database")
+}
+
+func (repo *PorterAppRepository) UpdatePorterApp(app *models.PorterApp) (*models.PorterApp, error) {
+	return nil, errors.New("cannot write database")
+}

+ 6 - 0
internal/repository/test/repository.go

@@ -49,6 +49,7 @@ type TestRepository struct {
 	monitor                   repository.MonitorTestResultRepository
 	apiContractRevision       repository.APIContractRevisioner
 	awsAssumeRoleChainer      repository.AWSAssumeRoleChainer
+	porterApp                 repository.PorterAppRepository
 }
 
 func (t *TestRepository) User() repository.UserRepository {
@@ -227,6 +228,10 @@ func (t *TestRepository) AWSAssumeRoleChainer() repository.AWSAssumeRoleChainer
 	return t.awsAssumeRoleChainer
 }
 
+func (t *TestRepository) PorterApp() repository.PorterAppRepository {
+	return t.porterApp
+}
+
 // NewRepository returns a Repository which persists users in memory
 // and accepts a parameter that can trigger read/write errors
 func NewRepository(canQuery bool, failingMethods ...string) repository.Repository {
@@ -275,5 +280,6 @@ func NewRepository(canQuery bool, failingMethods ...string) repository.Repositor
 		monitor:                   NewMonitorTestResultRepository(canQuery),
 		apiContractRevision:       NewAPIContractRevisioner(),
 		awsAssumeRoleChainer:      NewAWSAssumeRoleChainer(),
+		porterApp:                 NewPorterAppRepository(canQuery, failingMethods...),
 	}
 }