示例#1
0
func TestStart(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("multiple_script_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)
	sv := runit.FakeSV()
	executables, err := hl.Executables(sb)
	outFilePath := path.Join(sb.ConfigRoot, "testPod__testLaunchable.yaml")

	sbContentsMap := map[string]interface{}{
		executables[0].Service.Name: map[string]interface{}{
			"run": executables[0].Exec,
		},
		executables[1].Service.Name: map[string]interface{}{
			"run": executables[1].Exec,
		},
	}
	sbContents, err := yaml.Marshal(sbContentsMap)
	Assert(t).IsNil(err, "should have no error marshalling servicebuilder map")
	f, err := os.Open(outFilePath)
	defer f.Close()
	f.Write(sbContents)

	err = hl.start(sb, sv)

	Assert(t).IsNil(err, "Got an unexpected error when attempting to start runit services")

}
示例#2
0
func TestLaunchWithPassingEnable(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	sv := runit.FakeSV()
	err := hl.Launch(sb, sv)
	Assert(t).IsNil(err, "Expected launch to succeed")
}
示例#3
0
func TestStop(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("multiple_script_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	sv := runit.FakeSV()
	err := hl.stop(sb, sv)

	Assert(t).IsNil(err, "Got an unexpected error when attempting to stop runit services")
}
示例#4
0
func TestHaltWithPassingDisable(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	sv := runit.FakeSV()
	err := hl.Halt(sb, sv)
	Assert(t).IsNil(err, "Expected halt to succeed")

	Assert(t).IsNil(os.Remove(hl.LastDir()), "expected halt to create last symlink")
}
示例#5
0
func TestLaunchWithFailingEnable(t *testing.T) {
	hl, sb := FakeHoistLaunchableForDir("failing_scripts_test_hoist_launchable")
	defer CleanupFakeLaunchable(hl, sb)

	sv := runit.FakeSV()
	err := hl.Launch(sb, sv)
	Assert(t).IsNotNil(err, "Expected error while launching")
	_, ok := err.(launch.EnableError)
	Assert(t).IsTrue(ok, "Expected enable error to be returned")
	_, ok = err.(launch.StartError)
	Assert(t).IsFalse(ok, "Did not expect start error to be returned")
}