Beispiel #1
0
func (s *backupsSuite) TestNewAPIOkay(c *gc.C) {
	api, err := backups.NewAPI(s.State, s.resources, s.authorizer)
	c.Assert(err, gc.IsNil)
	st, backupsImpl := backups.APIValues(api)

	c.Check(st, gc.Equals, s.State)
	c.Check(backupsImpl, gc.NotNil)
}
Beispiel #2
0
func (s *backupsSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.resources = common.NewResources()
	tag := names.NewUserTag("spam")
	s.authorizer = &apiservertesting.FakeAuthorizer{Tag: tag}
	var err error
	s.api, err = backups.NewAPI(s.State, s.resources, s.authorizer)
	c.Assert(err, gc.IsNil)
	s.meta = s.newMeta("")
}
Beispiel #3
0
func (s *backupsSuite) SetUpTest(c *gc.C) {
	s.JujuConnSuite.SetUpTest(c)
	s.resources = common.NewResources()
	s.resources.RegisterNamed("dataDir", common.StringResource("/var/lib/juju"))
	tag := names.NewLocalUserTag("spam")
	s.authorizer = &apiservertesting.FakeAuthorizer{Tag: tag}
	var err error
	s.api, err = backupsAPI.NewAPI(s.State, s.resources, s.authorizer)
	c.Assert(err, jc.ErrorIsNil)
	s.meta = backupstesting.NewMetadataStarted()
}
Beispiel #4
0
func (s *backupsSuite) TestNewAPINotAuthorized(c *gc.C) {
	s.authorizer.Tag = names.NewServiceTag("eggs")
	_, err := backupsAPI.NewAPI(s.State, s.resources, s.authorizer)

	c.Check(errors.Cause(err), gc.Equals, common.ErrPerm)
}
Beispiel #5
0
func (s *backupsSuite) TestNewAPIOkay(c *gc.C) {
	_, err := backupsAPI.NewAPI(s.State, s.resources, s.authorizer)
	c.Check(err, jc.ErrorIsNil)
}
Beispiel #6
0
func (s *backupsSuite) TestNewAPIHostedEnvironmentFails(c *gc.C) {
	otherState := factory.NewFactory(s.State).MakeModel(c, nil)
	defer otherState.Close()
	_, err := backupsAPI.NewAPI(&stateShim{otherState}, s.resources, s.authorizer)
	c.Check(err, gc.ErrorMatches, "backups are not supported for hosted models")
}