~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/environs/testing/storage.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package testing
 
5
 
 
6
import (
 
7
        "io"
 
8
 
 
9
        jc "github.com/juju/testing/checkers"
 
10
        gc "gopkg.in/check.v1"
 
11
 
 
12
        "github.com/juju/juju/environs/filestorage"
 
13
        "github.com/juju/juju/environs/storage"
 
14
)
 
15
 
 
16
// CreateLocalTestStorage returns the listener, which needs to be closed, and
 
17
// the storage that is backed by a directory created in the running test's temp
 
18
// directory.
 
19
func CreateLocalTestStorage(c *gc.C) (closer io.Closer, stor storage.Storage, dataDir string) {
 
20
        dataDir = c.MkDir()
 
21
        underlying, err := filestorage.NewFileStorageWriter(dataDir)
 
22
        c.Assert(err, jc.ErrorIsNil)
 
23
        return nopCloser{}, underlying, dataDir
 
24
}
 
25
 
 
26
type nopCloser struct{}
 
27
 
 
28
func (nopCloser) Close() error {
 
29
        return nil
 
30
}