func TestFailingStart(t *testing.T) { hl, sb := FakeHoistLaunchableForDir("multiple_script_test_hoist_launchable") defer CleanupFakeLaunchable(hl, sb) sv := runit.ErringSV() executables, _ := 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).IsNotNil(err, "Expected an error starting runit services") }
func TestStopWithFailure(t *testing.T) { hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable") defer CleanupFakeLaunchable(hl, sb) sv := runit.ErringSV() err := hl.Stop(sb, sv) Assert(t).IsNotNil(err, "Expected error while halting") _, ok := err.(launch.StopError) Assert(t).IsTrue(ok, "Expected stop error to be returned") }
func TestFailingStop(t *testing.T) { hl, sb := FakeHoistLaunchableForDir("multiple_script_test_hoist_launchable") defer CleanupFakeLaunchable(hl, sb) sv := runit.ErringSV() err := hl.stop(sb, sv) Assert(t).IsNotNil(err, "Expected sv stop to fail for this test, but it didn't") }
func TestLaunchWithFailingStart(t *testing.T) { hl, sb := FakeHoistLaunchableForDir("successful_scripts_test_hoist_launchable") defer CleanupFakeLaunchable(hl, sb) sv := runit.ErringSV() err := hl.Launch(sb, sv) Assert(t).IsNotNil(err, "Expected error while launching") _, ok := err.(launch.StartError) Assert(t).IsTrue(ok, "Expected start error to be returned") _, ok = err.(launch.EnableError) Assert(t).IsFalse(ok, "Did not expect enable error to be returned") }