Пример #1
0
func (deps *contextDeps) NewTempDirSpec() (internal.DownloadTempTarget, error) {
	spec, err := internal.NewTempDirectorySpec(deps.name, deps)
	if err != nil {
		return nil, errors.Trace(err)
	}
	dir := &internal.ContextDownloadDirectory{
		spec,
	}
	return dir, nil
}
Пример #2
0
func (s *TempDirectorySpecSuite) TestClose(c *gc.C) {
	s.stub.ReturnNewTempDir = "/tmp/juju-resource-xyz"
	deps := s.stub
	spec, err := internal.NewTempDirectorySpec("eggs", deps)
	c.Assert(err, jc.ErrorIsNil)
	s.stub.ResetCalls()

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

	s.stub.CheckCallNames(c, "RemoveDir")
}
Пример #3
0
func (s *TempDirectorySpecSuite) TestNewTempDirectorySpec(c *gc.C) {
	s.stub.ReturnNewTempDir = "/tmp/juju-resource-xyz"
	deps := s.stub

	spec, err := internal.NewTempDirectorySpec("eggs", deps)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "NewTempDir", "Join")
	c.Check(spec.CleanUp, gc.NotNil) // We can't compare functions.
	spec.CleanUp = nil
	c.Check(spec, jc.DeepEquals, &internal.TempDirectorySpec{
		DirectorySpec: &internal.DirectorySpec{
			Name:    "eggs",
			Dirname: "/tmp/juju-resource-xyz/eggs",
			Deps:    deps,
		},
	})
}