github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/apiserver/backups/list_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) TestListOkay(c *gc.C) {
    18  	impl := s.setBackups(c, s.meta, "")
    19  	impl.Archive = ioutil.NopCloser(bytes.NewBufferString("spamspamspam"))
    20  	args := params.BackupsListArgs{}
    21  	result, err := s.api.List(args)
    22  	c.Assert(err, jc.ErrorIsNil)
    23  
    24  	item := backups.ResultFromMetadata(s.meta)
    25  	expected := params.BackupsListResult{
    26  		List: []params.BackupsMetadataResult{item},
    27  	}
    28  
    29  	c.Check(result, gc.DeepEquals, expected)
    30  }
    31  
    32  func (s *backupsSuite) TestListError(c *gc.C) {
    33  	s.setBackups(c, nil, "failed!")
    34  	args := params.BackupsListArgs{}
    35  	_, err := s.api.List(args)
    36  
    37  	c.Check(err, gc.ErrorMatches, "failed!")
    38  }