github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/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 c.Check(result, gc.DeepEquals, expected) 27 } 28 29 func (s *backupsSuite) TestInfoMissingFile(c *gc.C) { 30 s.setBackups(c, s.meta, "") 31 args := params.BackupsInfoArgs{ 32 ID: "some-id", 33 } 34 result, err := s.api.Info(args) 35 c.Assert(err, jc.ErrorIsNil) 36 expected := backups.ResultFromMetadata(s.meta) 37 38 c.Check(result, gc.DeepEquals, expected) 39 } 40 41 func (s *backupsSuite) TestInfoError(c *gc.C) { 42 s.setBackups(c, nil, "failed!") 43 args := params.BackupsInfoArgs{ 44 ID: "some-id", 45 } 46 _, err := s.api.Info(args) 47 48 c.Check(err, gc.ErrorMatches, "failed!") 49 }