Files
fn_registry/functions/infra/ssh_check_test.go
T
egutierrez 560cbf280e feat: funciones SSH para infra — conn, check, exec, download, upload, tunnel
Conjunto completo de funciones SSH para operaciones remotas: conexión,
verificación de host, ejecución de comandos, transferencia de archivos
(upload/download) y gestión de túneles. Incluye tipo SSHConn y tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 22:03:41 +02:00

41 lines
797 B
Go

package infra
import (
"testing"
)
func sshTestConn() SSHConn {
return SSHConn{
Host: "organic-machine.com",
User: "ubuntu",
KeyPath: "/home/lucas/.ssh/organic-machine",
}
}
func skipIfNoSSH(t *testing.T) SSHConn {
t.Helper()
conn := sshTestConn()
if err := SSHCheck(conn); err != nil {
t.Skipf("SSH no disponible: %v", err)
}
return conn
}
func TestSSHCheck(t *testing.T) {
t.Run("conecta a organic-machine", func(t *testing.T) {
conn := sshTestConn()
err := SSHCheck(conn)
if err != nil {
t.Skipf("SSH no disponible: %v", err)
}
})
t.Run("falla con host inexistente", func(t *testing.T) {
conn := SSHConn{Host: "192.0.2.1", Port: 22, User: "nobody"}
err := SSHCheck(conn)
if err == nil {
t.Error("esperaba error con host inexistente")
}
})
}