示例#1
0
文件: gofig_test.go 项目: akutz/gofig
func TestNewWithUserConfigFileWithErrors(t *testing.T) {
	_, usrCfgFilePath := newConfigDirs("TestNewWithUserConfigFileWithErrors", t)
	gotil.WriteStringToFile(string(yamlConfig1), usrCfgFilePath)

	os.Chmod(usrCfgFilePath, 0000)
	New()
}
示例#2
0
// 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())
}
示例#3
0
文件: gofig_test.go 项目: akutz/gofig
func TestNewWithGlobalConfigFileWithErrors(t *testing.T) {
	etcCfgFilePath, _ := newConfigDirs(
		"TestNewWithGlobalConfigFileWithErrors", t)

	t.Logf("etcCfgFilePath=%s", etcCfgFilePath)
	gotil.WriteStringToFile(string(yamlConfig1), etcCfgFilePath)

	os.Chmod(etcCfgFilePath, 0000)
	New()
}
示例#4
0
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")
	}
}
示例#5
0
文件: gofig_test.go 项目: akutz/gofig
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)
}
示例#6
0
文件: gofig_test.go 项目: akutz/gofig
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)
}
示例#7
0
文件: util.go 项目: akutz/rexray
// WriteSpecFile writes the current host address to the REX-Ray spec file.
func WriteSpecFile(host string) error {
	return gotil.WriteStringToFile(host, SpecFilePath())
}