(t *testing.T)
| 760 | } |
| 761 | |
| 762 | func TestRunWatchSubcommandStopForeignPID(t *testing.T) { |
| 763 | root := t.TempDir() |
| 764 | |
| 765 | origRunning := watchIsRunning |
| 766 | origStop := stopWatchDaemon |
| 767 | defer func() { |
| 768 | watchIsRunning = origRunning |
| 769 | stopWatchDaemon = origStop |
| 770 | }() |
| 771 | watchIsRunning = func(string) bool { return true } |
| 772 | stopWatchDaemon = func(string) error { return watch.ErrForeignDaemonPID } |
| 773 | |
| 774 | stdout, _ := captureMainStreams(t, func() { runWatchSubcommand("stop", root) }) |
| 775 | if !strings.Contains(stdout, "cleared stale PID file") { |
| 776 | t.Fatalf("expected stale-PID message on foreign PID, got:\n%s", stdout) |
| 777 | } |
| 778 | if strings.Contains(stdout, "Watch daemon stopped") { |
| 779 | t.Fatalf("should not claim the daemon was stopped for a foreign PID:\n%s", stdout) |
| 780 | } |
| 781 | } |
nothing calls this directly
no test coverage detected