Skip to content

Commit

Permalink
Fix state tests after removal of remote spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nvinuesa committed Mar 22, 2024
1 parent 0d47fb8 commit 14d6a6f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 28 deletions.
27 changes: 16 additions & 11 deletions apiserver/facades/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3181,28 +3181,33 @@
"Constraints": {
"type": "object",
"properties": {
"Attributes": {
"type": "object",
"patternProperties": {
".*": {
"type": "string"
}
}
},
"Count": {
"type": "integer"
},
"Pool": {
"Type": {
"type": "string"
},
"Size": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"Pool",
"Size",
"Count"
"Type",
"Count",
"Attributes"
]
},
"ConsumeApplicationArg": {
"ConsumeApplicationArgV5": {
"type": "object",
"properties": {
"ApplicationOfferDetails": {
"$ref": "#/definitions/ApplicationOfferDetails"
"ApplicationOfferDetailsV5": {
"$ref": "#/definitions/ApplicationOfferDetailsV5"
},
"application-alias": {
"type": "string"
Expand Down Expand Up @@ -47343,4 +47348,4 @@
}
}
}
]
]
37 changes: 29 additions & 8 deletions state/migration_export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,35 @@ func (s *MigrationExportSuite) newResource(c *gc.C, appName, name string, revisi
}

func (s *MigrationExportSuite) TestRemoteApplications(c *gc.C) {
mac, err := newMacaroon("apimac")
c.Assert(err, gc.IsNil)
_, err = s.State.AddRemoteApplication(state.AddRemoteApplicationParams{
Name: "gravy-rainbow",
URL: "me/model.rainbow",
SourceModel: s.Model.ModelTag(),
Token: "charisma",
OfferUUID: "offer-uuid",
Endpoints: []charm.Relation{{
Interface: "mysql",
Name: "db",
Role: charm.RoleProvider,
Scope: charm.ScopeGlobal,
}, {
Interface: "mysql-root",
Name: "db-admin",
Limit: 5,
Role: charm.RoleProvider,
Scope: charm.ScopeGlobal,
}, {
Interface: "logging",
Name: "logging",
Role: charm.RoleProvider,
Scope: charm.ScopeGlobal,
}},
// Macaroon not exported.
Macaroon: mac,
})
c.Assert(err, jc.ErrorIsNil)
state.AddTestingApplication(c, s.State, s.objectStore, "wordpress", state.AddTestingCharm(c, s.State, "wordpress"))
eps, err := s.State.InferEndpoints("gravy-rainbow", "wordpress")
c.Assert(err, jc.ErrorIsNil)
Expand All @@ -2175,11 +2204,6 @@ func (s *MigrationExportSuite) TestRemoteApplications(c *gc.C) {
c.Check(app.URL(), gc.Equals, "me/model.rainbow")
c.Check(app.SourceModelTag(), gc.Equals, s.Model.ModelTag())
c.Check(app.IsConsumerProxy(), jc.IsFalse)
c.Check(app.Bindings(), gc.DeepEquals, map[string]string{
"db": "private",
"db-admin": "private",
"logging": "public",
})

c.Assert(app.Endpoints(), gc.HasLen, 3)
ep := app.Endpoints()[0]
Expand All @@ -2195,9 +2219,6 @@ func (s *MigrationExportSuite) TestRemoteApplications(c *gc.C) {
c.Check(ep.Interface(), gc.Equals, "logging")
c.Check(ep.Role(), gc.Equals, "provider")

actualSpaces := app.Spaces()
c.Assert(actualSpaces, gc.HasLen, 2)

c.Assert(model.Relations(), gc.HasLen, 1)
rel := model.Relations()[0]
c.Assert(rel.Key(), gc.Equals, "wordpress:db gravy-rainbow:db")
Expand Down
9 changes: 0 additions & 9 deletions state/migrations/remoteapplications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func (s *RemoteApplicationsExportSuite) TestExportRemoteApplication(c *gc.C) {
IsConsumerProxy: false,
Macaroon: "mac",
ConsumeVersion: 1,
Bindings: map[string]string{
"binding-key": "binding-value",
},
}).Return(remoteApplication)

migration := ExportRemoteApplications{}
Expand Down Expand Up @@ -130,9 +127,6 @@ func (s *RemoteApplicationsExportSuite) TestExportRemoteApplicationWithEndpoints
IsConsumerProxy: false,
Macaroon: "mac",
ConsumeVersion: 1,
Bindings: map[string]string{
"binding-key": "binding-value",
},
}).Return(remoteApplication)

migration := ExportRemoteApplications{}
Expand Down Expand Up @@ -174,9 +168,6 @@ func (s *RemoteApplicationsExportSuite) TestExportRemoteApplicationWithStatusArg
IsConsumerProxy: false,
Macaroon: "mac",
ConsumeVersion: 1,
Bindings: map[string]string{
"binding-key": "binding-value",
},
}).Return(remoteApplication)

migration := ExportRemoteApplications{}
Expand Down

0 comments on commit 14d6a6f

Please sign in to comment.