53
53
c.Assert(client.Close(), gc.IsNil)
56
func (s *clientSuite) TestUploadToolsOtherEnvironment(c *gc.C) {
57
otherSt, otherAPISt := s.otherEnviron(c)
56
func (s *clientSuite) TestUploadToolsOtherModel(c *gc.C) {
57
otherSt, otherAPISt := s.otherModel(c)
58
58
defer otherSt.Close()
59
59
defer otherAPISt.Close()
60
60
client := otherAPISt.Client()
117
117
c.Assert(savedURL.String(), gc.Equals, curl.WithRevision(43).String())
120
func (s *clientSuite) TestAddLocalCharmOtherEnvironment(c *gc.C) {
120
func (s *clientSuite) TestAddLocalCharmOtherModel(c *gc.C) {
121
121
charmArchive := testcharms.Repo.CharmArchive(c.MkDir(), "dummy")
122
122
curl := charm.MustParseURL(
123
123
fmt.Sprintf("local:quantal/%s-%d", charmArchive.Meta().Name, charmArchive.Revision()),
126
otherSt, otherAPISt := s.otherEnviron(c)
126
otherSt, otherAPISt := s.otherModel(c)
127
127
defer otherSt.Close()
128
128
defer otherAPISt.Close()
129
129
client := otherAPISt.Client()
138
138
c.Assert(charm.String(), gc.Equals, curl.String())
141
func (s *clientSuite) otherEnviron(c *gc.C) (*state.State, api.Connection) {
141
func (s *clientSuite) otherModel(c *gc.C) (*state.State, api.Connection) {
142
142
otherSt := s.Factory.MakeModel(c, nil)
143
143
info := s.APIInfo(c)
144
144
info.ModelTag = otherSt.ModelTag()
277
277
_, err := client.OpenCharm(curl)
279
c.Check(err, gc.ErrorMatches, `.*unable to retrieve and save the charm: cannot get charm from state: charm "cs:quantal/spam-3" not found`)
279
c.Check(err, gc.ErrorMatches, `.*cannot get charm from state: charm "cs:quantal/spam-3" not found`)
282
282
func addLocalCharm(c *gc.C, client *api.Client, name string) (*charm.URL, *charm.CharmArchive) {
311
311
return path.Join("/model", modelTag.Id(), destination)
314
func (s *clientSuite) TestClientEnvironmentUUID(c *gc.C) {
315
environ, err := s.State.Model()
314
func (s *clientSuite) TestClientModelUUID(c *gc.C) {
315
model, err := s.State.Model()
316
316
c.Assert(err, jc.ErrorIsNil)
318
318
client := s.APIState.Client()
319
319
uuid, ok := client.ModelUUID()
320
320
c.Assert(ok, jc.IsTrue)
321
c.Assert(uuid, gc.Equals, environ.Tag().Id())
321
c.Assert(uuid, gc.Equals, model.Tag().Id())
324
func (s *clientSuite) TestClientEnvironmentUsers(c *gc.C) {
324
func (s *clientSuite) TestClientModelUsers(c *gc.C) {
325
325
client := s.APIState.Client()
326
326
cleanup := api.PatchClientFacadeCall(client,
327
327
func(request string, paramsIn interface{}, response interface{}) error {
442
442
func (s *clientSuite) TestConnectStreamAtUUIDPath(c *gc.C) {
443
443
catcher := urlCatcher{}
444
444
s.PatchValue(api.WebsocketDialConfig, catcher.recordLocation)
445
environ, err := s.State.Model()
445
model, err := s.State.Model()
446
446
c.Assert(err, jc.ErrorIsNil)
447
447
info := s.APIInfo(c)
448
info.ModelTag = environ.ModelTag()
448
info.ModelTag = model.ModelTag()
449
449
apistate, err := api.Open(info, api.DialOpts{})
450
450
c.Assert(err, jc.ErrorIsNil)
451
451
defer apistate.Close()
452
452
_, err = apistate.ConnectStream("/path", nil)
453
453
c.Assert(err, jc.ErrorIsNil)
454
454
connectURL := catcher.location
455
c.Assert(connectURL.Path, gc.Matches, fmt.Sprintf("/model/%s/path", environ.UUID()))
455
c.Assert(connectURL.Path, gc.Matches, fmt.Sprintf("/model/%s/path", model.UUID()))
458
458
func (s *clientSuite) TestOpenUsesModelUUIDPaths(c *gc.C) {
459
459
info := s.APIInfo(c)
461
461
// Passing in the correct model UUID should work
462
environ, err := s.State.Model()
462
model, err := s.State.Model()
463
463
c.Assert(err, jc.ErrorIsNil)
464
info.ModelTag = environ.ModelTag()
464
info.ModelTag = model.ModelTag()
465
465
apistate, err := api.Open(info, api.DialOpts{})
466
466
c.Assert(err, jc.ErrorIsNil)