]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/main_sync_test.go
safcm: don't hang on error before a connection is established
[safcm/safcm.git] / cmd / safcm / main_sync_test.go
index 16aad166cb5c854842453f89659901dfd959f3d7..fdbe98fba8764565551f7d4e8845789957c12db4 100644 (file)
@@ -348,6 +348,20 @@ executed 2 command(s):
        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 {