serverconfig: fix test on OS X

Change-Id: Ic5a8f820abe3cad920a18991cc21b5386fdf9553
This commit is contained in:
Brad Fitzpatrick 2013-01-11 10:52:22 -08:00
parent 446f03619c
commit 4be9f2f264
3 changed files with 13 additions and 2 deletions

View File

@ -17,3 +17,7 @@ limitations under the License.
package serverconfig package serverconfig
var GenLowLevelConfig = genLowLevelConfig var GenLowLevelConfig = genLowLevelConfig
func SetTempDirFunc(f func() string) {
tempDir = f
}

View File

@ -38,6 +38,8 @@ type configPrefixesParams struct {
searchOwner *blobref.BlobRef searchOwner *blobref.BlobRef
} }
var tempDir = os.TempDir
func addPublishedConfig(prefixes jsonconfig.Obj, published jsonconfig.Obj) ([]interface{}, error) { func addPublishedConfig(prefixes jsonconfig.Obj, published jsonconfig.Obj) ([]interface{}, error) {
pubPrefixes := []interface{}{} pubPrefixes := []interface{}{}
for k, v := range published { for k, v := range published {
@ -214,7 +216,7 @@ func addS3Config(prefixes jsonconfig.Obj, s3 string) error {
prefixes["/cache/"] = map[string]interface{}{ prefixes["/cache/"] = map[string]interface{}{
"handler": "storage-filesystem", "handler": "storage-filesystem",
"handlerArgs": map[string]interface{}{ "handlerArgs": map[string]interface{}{
"path": filepath.Join(os.TempDir(), "camli-cache"), "path": filepath.Join(tempDir(), "camli-cache"),
}, },
} }
} else { } else {
@ -436,7 +438,7 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
// a temp dir as the cache when primary storage is S3. // a temp dir as the cache when primary storage is S3.
// TODO(mpl): s3CacheBucket // TODO(mpl): s3CacheBucket
// See http://code.google.com/p/camlistore/issues/detail?id=85 // See http://code.google.com/p/camlistore/issues/detail?id=85
cacheDir = filepath.Join(os.TempDir(), "camli-cache") cacheDir = filepath.Join(tempDir(), "camli-cache")
} else { } else {
cacheDir = filepath.Join(blobPath, "/cache") cacheDir = filepath.Join(blobPath, "/cache")
} }

View File

@ -33,6 +33,11 @@ import (
"camlistore.org/pkg/serverconfig" "camlistore.org/pkg/serverconfig"
) )
func init() {
// Avoid Linux vs. OS X differences in tests.
serverconfig.SetTempDirFunc(func() string { return "/tmp" })
}
func sortedKeys(m map[string]interface{}) (keys []string) { func sortedKeys(m map[string]interface{}) (keys []string) {
for k := range m { for k := range m {
keys = append(keys, k) keys = append(keys, k)