Example #1
0
func (s *workspaceSuite) TestNewArchiveWorkspaceReader(c *gc.C) {
	ws, err := backups.NewArchiveWorkspaceReader(s.archiveFile)
	c.Assert(err, jc.ErrorIsNil)
	defer ws.Close()

	c.Check(ws.RootDir, gc.Not(gc.Equals), "")
}
Example #2
0
func (s *workspaceSuite) TestClose(c *gc.C) {
	ws, err := backups.NewArchiveWorkspaceReader(s.archiveFile)
	c.Assert(err, jc.ErrorIsNil)

	err = ws.Close()
	c.Assert(err, jc.ErrorIsNil)

	_, err = os.Stat(ws.RootDir)
	c.Check(err, jc.Satisfies, os.IsNotExist)
}
Example #3
0
func (s *workspaceSuite) TestMetadata(c *gc.C) {
	ws, err := backups.NewArchiveWorkspaceReader(s.archiveFile)
	c.Assert(err, jc.ErrorIsNil)
	defer ws.Close()

	meta, err := ws.Metadata()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(meta, jc.DeepEquals, s.meta)
}
Example #4
0
func (s *workspaceSuite) TestOpenBundledFile(c *gc.C) {
	ws, err := backups.NewArchiveWorkspaceReader(s.archiveFile)
	c.Assert(err, jc.ErrorIsNil)
	defer ws.Close()

	file, err := ws.OpenBundledFile("var/lib/juju/system-identity")
	c.Assert(err, jc.ErrorIsNil)

	data, err := ioutil.ReadAll(file)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(string(data), gc.Equals, "<an ssh key goes here>")
}
Example #5
0
func (s *workspaceSuite) TestUnpackFilesBundle(c *gc.C) {
	ws, err := backups.NewArchiveWorkspaceReader(s.archiveFile)
	c.Assert(err, jc.ErrorIsNil)
	defer ws.Close()

	targetDir := c.MkDir()
	err = ws.UnpackFilesBundle(targetDir)
	c.Assert(err, jc.ErrorIsNil)

	_, err = os.Stat(targetDir + "/var/lib/juju/tools/1.21-alpha2.1-trusty-amd64/jujud")
	c.Assert(err, jc.ErrorIsNil)
	_, err = os.Stat(targetDir + "/var/lib/juju/system-identity")
	c.Assert(err, jc.ErrorIsNil)
}