logRegexp := regexp.MustCompile(`^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} `)
detectedRegexp := regexp.MustCompile(`detected_\S+`)
+ t.Run("error before connection is established", func(t *testing.T) {
+ // Fake $PATH so safcm cannot find the `ssh` binary.
+ path := os.Getenv("PATH")
+ os.Setenv("PATH", "")
+ defer os.Setenv("PATH", path)
+
+ cmd := exec.Command("../../../../../safcm",
+ "sync", "-n", "no-settings.example.org")
+ _, err := cmd.CombinedOutput()
+ if err == nil {
+ t.Errorf("err = nil")
+ }
+ })
+
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if tc.remove {
}
// Kill forcefully terminates the connection. It's safe to call Kill (and
-// Wait) multiple times.
+// Wait) multiple times. Calling it before Dial*() was called will only close
+// the Events channel.
func (c *Conn) Kill() error {
if c.cmd == nil {
+ if c.events != nil {
+ close(c.events)
+ c.events = nil
+ }
return fmt.Errorf("Dial*() not called or already terminated")
}