github.com/mwhudson/juju@v0.0.0-20160512215208-90ff01f3497f/environs/testing/storage.go (about) 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 }