Exemple #1
0
func NewDataDir(path string) (string, error) {
	var err error

	if path == "" {
		path = "~/chillax"
	}
	path = libenv.EnvWithDefault("CHILLAX_DATA_DIR", path)
	path = libstring.ExpandTildeAndEnv(path)

	err = os.MkdirAll(libstring.ExpandTildeAndEnv(path), 0755)
	if err != nil {
		return "", err
	}

	return path, nil
}
Exemple #2
0
func TestNewStoragesWithDefault(t *testing.T) {
	storages, err := NewStorages()
	if err != nil {
		t.Fatalf("Creating storages should not fail. Error: %v", err)
	}
	if _, err := os.Stat(libstring.ExpandTildeAndEnv("~/chillax/kv-db")); os.IsNotExist(err) {
		t.Fatal("Default key-value db file should exist.")
	}

	err = storages.RemoveAll()
	if err != nil {
		t.Fatalf("Wiping storage should work. Error: %v", err)
	}
}