зеркало из https://github.com/Azure/ARO-RP.git
update db fakes for maintmanifests
This commit is contained in:
Родитель
958b339427
Коммит
7525466fd8
|
@ -37,6 +37,10 @@ type DatabaseGroupWithPortal interface {
|
||||||
Portal() (Portal, error)
|
Portal() (Portal, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DatabaseGroupWithMaintenanceManifests interface {
|
||||||
|
MaintenanceManifests() (MaintenanceManifests, error)
|
||||||
|
}
|
||||||
|
|
||||||
type DatabaseGroup interface {
|
type DatabaseGroup interface {
|
||||||
DatabaseGroupWithOpenShiftClusters
|
DatabaseGroupWithOpenShiftClusters
|
||||||
DatabaseGroupWithSubscriptions
|
DatabaseGroupWithSubscriptions
|
||||||
|
@ -46,6 +50,7 @@ type DatabaseGroup interface {
|
||||||
DatabaseGroupWithAsyncOperations
|
DatabaseGroupWithAsyncOperations
|
||||||
DatabaseGroupWithBilling
|
DatabaseGroupWithBilling
|
||||||
DatabaseGroupWithPortal
|
DatabaseGroupWithPortal
|
||||||
|
DatabaseGroupWithMaintenanceManifests
|
||||||
|
|
||||||
WithOpenShiftClusters(db OpenShiftClusters) DatabaseGroup
|
WithOpenShiftClusters(db OpenShiftClusters) DatabaseGroup
|
||||||
WithSubscriptions(db Subscriptions) DatabaseGroup
|
WithSubscriptions(db Subscriptions) DatabaseGroup
|
||||||
|
@ -55,6 +60,7 @@ type DatabaseGroup interface {
|
||||||
WithAsyncOperations(db AsyncOperations) DatabaseGroup
|
WithAsyncOperations(db AsyncOperations) DatabaseGroup
|
||||||
WithBilling(db Billing) DatabaseGroup
|
WithBilling(db Billing) DatabaseGroup
|
||||||
WithPortal(db Portal) DatabaseGroup
|
WithPortal(db Portal) DatabaseGroup
|
||||||
|
WithMaintenanceManifests(db MaintenanceManifests) DatabaseGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
type dbGroup struct {
|
type dbGroup struct {
|
||||||
|
@ -66,6 +72,7 @@ type dbGroup struct {
|
||||||
asyncOperations AsyncOperations
|
asyncOperations AsyncOperations
|
||||||
billing Billing
|
billing Billing
|
||||||
portal Portal
|
portal Portal
|
||||||
|
maintenanceManifests MaintenanceManifests
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dbGroup) OpenShiftClusters() (OpenShiftClusters, error) {
|
func (d *dbGroup) OpenShiftClusters() (OpenShiftClusters, error) {
|
||||||
|
@ -164,6 +171,18 @@ func (d *dbGroup) WithPortal(db Portal) DatabaseGroup {
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dbGroup) MaintenanceManifests() (MaintenanceManifests, error) {
|
||||||
|
if d.maintenanceManifests == nil {
|
||||||
|
return nil, errors.New("no MaintenanceManifests defined")
|
||||||
|
}
|
||||||
|
return d.maintenanceManifests, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dbGroup) WithMaintenanceManifests(db MaintenanceManifests) DatabaseGroup {
|
||||||
|
d.maintenanceManifests = db
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
func NewDBGroup() DatabaseGroup {
|
func NewDBGroup() DatabaseGroup {
|
||||||
return &dbGroup{}
|
return &dbGroup{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-test/deep"
|
"github.com/go-test/deep"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -83,6 +84,8 @@ type testInfra struct {
|
||||||
openShiftVersionsDatabase database.OpenShiftVersions
|
openShiftVersionsDatabase database.OpenShiftVersions
|
||||||
platformWorkloadIdentityRoleSetsClient *cosmosdb.FakePlatformWorkloadIdentityRoleSetDocumentClient
|
platformWorkloadIdentityRoleSetsClient *cosmosdb.FakePlatformWorkloadIdentityRoleSetDocumentClient
|
||||||
platformWorkloadIdentityRoleSetsDatabase database.PlatformWorkloadIdentityRoleSets
|
platformWorkloadIdentityRoleSetsDatabase database.PlatformWorkloadIdentityRoleSets
|
||||||
|
maintenanceManifestsClient *cosmosdb.FakeMaintenanceManifestDocumentClient
|
||||||
|
maintenanceManifestsDatabase database.MaintenanceManifests
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestInfra(t *testing.T) *testInfra {
|
func newTestInfra(t *testing.T) *testInfra {
|
||||||
|
@ -204,6 +207,13 @@ func (ti *testInfra) WithClusterManagerConfigurations() *testInfra {
|
||||||
return ti
|
return ti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ti *testInfra) WithMaintenanceManifests(now func() time.Time) *testInfra {
|
||||||
|
ti.maintenanceManifestsDatabase, ti.maintenanceManifestsClient = testdatabase.NewFakeMaintenanceManifests(now)
|
||||||
|
ti.fixture.WithMaintenanceManifests(ti.maintenanceManifestsDatabase)
|
||||||
|
ti.dbGroup.WithMaintenanceManifests(ti.maintenanceManifestsDatabase)
|
||||||
|
return ti
|
||||||
|
}
|
||||||
|
|
||||||
func (ti *testInfra) done() {
|
func (ti *testInfra) done() {
|
||||||
ti.controller.Finish()
|
ti.controller.Finish()
|
||||||
ti.cli.CloseIdleConnections()
|
ti.cli.CloseIdleConnections()
|
||||||
|
@ -254,7 +264,7 @@ func (ti *testInfra) request(method, url string, header http.Header, in interfac
|
||||||
|
|
||||||
func validateResponse(resp *http.Response, b []byte, wantStatusCode int, wantError string, wantResponse interface{}) error {
|
func validateResponse(resp *http.Response, b []byte, wantStatusCode int, wantError string, wantResponse interface{}) error {
|
||||||
if resp.StatusCode != wantStatusCode {
|
if resp.StatusCode != wantStatusCode {
|
||||||
return fmt.Errorf("unexpected status code %d, wanted %d", resp.StatusCode, wantStatusCode)
|
return fmt.Errorf("unexpected status code %d, wanted %d: %s", resp.StatusCode, wantStatusCode, string(b))
|
||||||
}
|
}
|
||||||
|
|
||||||
if wantError != "" {
|
if wantError != "" {
|
||||||
|
@ -264,8 +274,8 @@ func validateResponse(resp *http.Response, b []byte, wantStatusCode int, wantErr
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if cloudErr.Error() != wantError {
|
if diff := deep.Equal(cloudErr.Error(), wantError); diff != nil {
|
||||||
return fmt.Errorf("unexpected error %s, wanted %s", cloudErr.Error(), wantError)
|
return fmt.Errorf("unexpected error %s, wanted %s (%s)", cloudErr.Error(), wantError, diff)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Загрузка…
Ссылка в новой задаче