func TestNewWithUserConfigFileWithErrors(t *testing.T) { _, usrCfgFilePath := newConfigDirs("TestNewWithUserConfigFileWithErrors", t) gotil.WriteStringToFile(string(yamlConfig1), usrCfgFilePath) os.Chmod(usrCfgFilePath, 0000) New() }
// WritePidFile writes the current process ID to the REX-Ray PID file. func WritePidFile(pid int) error { if pid < 0 { pid = os.Getpid() } return gotil.WriteStringToFile(fmt.Sprintf("%d", pid), PidFilePath()) }
func TestNewWithGlobalConfigFileWithErrors(t *testing.T) { etcCfgFilePath, _ := newConfigDirs( "TestNewWithGlobalConfigFileWithErrors", t) t.Logf("etcCfgFilePath=%s", etcCfgFilePath) gotil.WriteStringToFile(string(yamlConfig1), etcCfgFilePath) os.Chmod(etcCfgFilePath, 0000) New() }
func TestReadPidFileWithErrors(t *testing.T) { newPrefixDir("TestWriteReadPidFile", t) var err error if _, err = ReadPidFile(); err == nil { t.Fatal("error expected in reading pid file") } gotil.WriteStringToFile("hello", PidFilePath()) if _, err = ReadPidFile(); err == nil { t.Fatal("error expected in reading pid file") } }
func TestNewWithUserConfigFile(t *testing.T) { _, usrCfgFilePath := newConfigDirs("TestNewWithUserConfigFile", t) gotil.WriteStringToFile(string(yamlConfig1), usrCfgFilePath) c := New() assertString(t, c, "rexray.logLevel", "error") assertStorageDrivers(t, c) assertOsDrivers1(t, c) if err := c.ReadConfig(bytes.NewReader(yamlConfig2)); err != nil { t.Fatal(err) } assertString(t, c, "rexray.logLevel", "debug") assertStorageDrivers(t, c) assertOsDrivers2(t, c) }
func TestCopy(t *testing.T) { etcCfgFilePath, _ := newConfigDirs("TestCopy", t) wipeEnv() Register(testReg3()) t.Logf("etcCfgFilePath=%s", etcCfgFilePath) gotil.WriteStringToFile(string(yamlConfig1), etcCfgFilePath) c1 := New() assertString(t, c1, "rexray.logLevel", "error") assertStorageDrivers(t, c1) assertOsDrivers1(t, c1) c2, _ := c1.Copy() assertString(t, c2, "rexray.logLevel", "error") assertStorageDrivers(t, c2) assertOsDrivers1(t, c2) assertConfigsEqual(c1, c2, t) }
// WriteSpecFile writes the current host address to the REX-Ray spec file. func WriteSpecFile(host string) error { return gotil.WriteStringToFile(host, SpecFilePath()) }