github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/apiserver/backups/info_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package backups_test
     5  
     6  import (
     7  	"bytes"
     8  	"io/ioutil"
     9  
    10  	jc "github.com/juju/testing/checkers"
    11  	gc "gopkg.in/check.v1"
    12  
    13  	"github.com/juju/juju/apiserver/backups"
    14  	"github.com/juju/juju/apiserver/params"
    15  )
    16  
    17  func (s *backupsSuite) TestInfoOkay(c *gc.C) {
    18  	impl := s.setBackups(c, s.meta, "")
    19  	impl.Archive = ioutil.NopCloser(bytes.NewBufferString("spamspamspam"))
    20  	args := params.BackupsInfoArgs{
    21  		ID: "some-id",
    22  	}
    23  	result, err := s.api.Info(args)
    24  	c.Assert(err, jc.ErrorIsNil)
    25  	expected := backups.ResultFromMetadata(s.meta)
    26  
    27  	c.Check(result, gc.DeepEquals, expected)
    28  }
    29  
    30  func (s *backupsSuite) TestInfoMissingFile(c *gc.C) {
    31  	s.setBackups(c, s.meta, "")
    32  	args := params.BackupsInfoArgs{
    33  		ID: "some-id",
    34  	}
    35  	result, err := s.api.Info(args)
    36  	c.Assert(err, jc.ErrorIsNil)
    37  	expected := backups.ResultFromMetadata(s.meta)
    38  
    39  	c.Check(result, gc.DeepEquals, expected)
    40  }
    41  
    42  func (s *backupsSuite) TestInfoError(c *gc.C) {
    43  	s.setBackups(c, nil, "failed!")
    44  	args := params.BackupsInfoArgs{
    45  		ID: "some-id",
    46  	}
    47  	_, err := s.api.Info(args)
    48  
    49  	c.Check(err, gc.ErrorMatches, "failed!")
    50  }