зеркало из 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)
|
||||
}
|
||||
|
||||
type DatabaseGroupWithMaintenanceManifests interface {
|
||||
MaintenanceManifests() (MaintenanceManifests, error)
|
||||
}
|
||||
|
||||
type DatabaseGroup interface {
|
||||
DatabaseGroupWithOpenShiftClusters
|
||||
DatabaseGroupWithSubscriptions
|
||||
|
@ -46,6 +50,7 @@ type DatabaseGroup interface {
|
|||
DatabaseGroupWithAsyncOperations
|
||||
DatabaseGroupWithBilling
|
||||
DatabaseGroupWithPortal
|
||||
DatabaseGroupWithMaintenanceManifests
|
||||
|
||||
WithOpenShiftClusters(db OpenShiftClusters) DatabaseGroup
|
||||
WithSubscriptions(db Subscriptions) DatabaseGroup
|
||||
|
@ -55,6 +60,7 @@ type DatabaseGroup interface {
|
|||
WithAsyncOperations(db AsyncOperations) DatabaseGroup
|
||||
WithBilling(db Billing) DatabaseGroup
|
||||
WithPortal(db Portal) DatabaseGroup
|
||||
WithMaintenanceManifests(db MaintenanceManifests) DatabaseGroup
|
||||
}
|
||||
|
||||
type dbGroup struct {
|
||||
|
@ -66,6 +72,7 @@ type dbGroup struct {
|
|||
asyncOperations AsyncOperations
|
||||
billing Billing
|
||||
portal Portal
|
||||
maintenanceManifests MaintenanceManifests
|
||||
}
|
||||
|
||||
func (d *dbGroup) OpenShiftClusters() (OpenShiftClusters, error) {
|
||||
|
@ -164,6 +171,18 @@ func (d *dbGroup) WithPortal(db Portal) DatabaseGroup {
|
|||
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 {
|
||||
return &dbGroup{}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
"net/http"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-test/deep"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -83,6 +84,8 @@ type testInfra struct {
|
|||
openShiftVersionsDatabase database.OpenShiftVersions
|
||||
platformWorkloadIdentityRoleSetsClient *cosmosdb.FakePlatformWorkloadIdentityRoleSetDocumentClient
|
||||
platformWorkloadIdentityRoleSetsDatabase database.PlatformWorkloadIdentityRoleSets
|
||||
maintenanceManifestsClient *cosmosdb.FakeMaintenanceManifestDocumentClient
|
||||
maintenanceManifestsDatabase database.MaintenanceManifests
|
||||
}
|
||||
|
||||
func newTestInfra(t *testing.T) *testInfra {
|
||||
|
@ -204,6 +207,13 @@ func (ti *testInfra) WithClusterManagerConfigurations() *testInfra {
|
|||
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() {
|
||||
ti.controller.Finish()
|
||||
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 {
|
||||
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 != "" {
|
||||
|
@ -264,8 +274,8 @@ func validateResponse(resp *http.Response, b []byte, wantStatusCode int, wantErr
|
|||
return err
|
||||
}
|
||||
|
||||
if cloudErr.Error() != wantError {
|
||||
return fmt.Errorf("unexpected error %s, wanted %s", cloudErr.Error(), wantError)
|
||||
if diff := deep.Equal(cloudErr.Error(), wantError); diff != nil {
|
||||
return fmt.Errorf("unexpected error %s, wanted %s (%s)", cloudErr.Error(), wantError, diff)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Загрузка…
Ссылка в новой задаче