Ejemplo n.º 1
0
func (s *listSuite) TestList(c *gc.C) {
	cleanup := backups.PatchClientFacadeCall(s.client,
		func(req string, paramsIn interface{}, resp interface{}) error {
			c.Check(req, gc.Equals, "List")

			c.Assert(paramsIn, gc.FitsTypeOf, params.BackupsListArgs{})

			if result, ok := resp.(*params.BackupsListResult); ok {
				result.List = make([]params.BackupsMetadataResult, 1)
				result.List[0] = apiserverbackups.ResultFromMetadata(s.Meta)
			} else {
				c.Fatalf("wrong output structure")
			}
			return nil
		},
	)
	defer cleanup()

	result, err := s.client.List()
	c.Assert(err, jc.ErrorIsNil)

	c.Assert(result.List, gc.HasLen, 1)
	resultItem := result.List[0]
	s.checkMetadataResult(c, &resultItem, s.Meta)
}
Ejemplo n.º 2
0
func (s *createSuite) TestCreate(c *gc.C) {
	cleanup := backups.PatchClientFacadeCall(s.client,
		func(req string, paramsIn interface{}, resp interface{}) error {
			c.Check(req, gc.Equals, "Create")

			c.Assert(paramsIn, gc.FitsTypeOf, params.BackupsCreateArgs{})
			p := paramsIn.(params.BackupsCreateArgs)
			c.Check(p.Notes, gc.Equals, "important")

			if result, ok := resp.(*params.BackupsMetadataResult); ok {
				*result = apiserverbackups.ResultFromMetadata(s.Meta)
				result.Notes = p.Notes
			} else {
				c.Fatalf("wrong output structure")
			}
			return nil
		},
	)
	defer cleanup()

	result, err := s.client.Create("important")
	c.Assert(err, jc.ErrorIsNil)

	meta := backupstesting.UpdateNotes(s.Meta, "important")
	s.checkMetadataResult(c, result, meta)
}
Ejemplo n.º 3
0
func (s *removeSuite) TestRemove(c *gc.C) {
	cleanup := backups.PatchClientFacadeCall(s.client,
		func(req string, paramsIn interface{}, resp interface{}) error {
			c.Check(req, gc.Equals, "Remove")

			c.Assert(paramsIn, gc.FitsTypeOf, params.BackupsRemoveArgs{})

			c.Check(resp, gc.IsNil)
			return nil
		},
	)
	defer cleanup()

	err := s.client.Remove(s.Meta.ID())
	c.Assert(err, jc.ErrorIsNil)
}
Ejemplo n.º 4
0
func (s *infoSuite) TestInfo(c *gc.C) {
	cleanup := backups.PatchClientFacadeCall(s.client,
		func(req string, paramsIn interface{}, resp interface{}) error {
			c.Check(req, gc.Equals, "Info")

			c.Assert(paramsIn, gc.FitsTypeOf, params.BackupsInfoArgs{})
			p := paramsIn.(params.BackupsInfoArgs)
			c.Check(p.ID, gc.Equals, "spam")

			if result, ok := resp.(*params.BackupsMetadataResult); ok {
				*result = apiserverbackups.ResultFromMetadata(s.Meta)
			} else {
				c.Fatalf("wrong output structure")
			}
			return nil
		},
	)
	defer cleanup()

	result, err := s.client.Info("spam")
	c.Assert(err, jc.ErrorIsNil)

	s.checkMetadataResult(c, result, s.Meta)
}