messages_1737_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package reinstall_test
  2. import (
  3. "os/exec"
  4. "strings"
  5. "testing"
  6. "github.com/gnacho/netpulse/server-go/internal/reinstall"
  7. )
  8. // #1737: un fallo del instalador tiene que dejar rastro en stderr. El servidor
  9. // ya devuelve esa ultima linea al operador, pero un wget silencioso o un
  10. // opkg que falla sin decir nada dejaban solo "Process exited with status 1".
  11. func TestScriptExplainsItsFailures(t *testing.T) {
  12. s := reinstall.ScriptWithTargets(
  13. "test-router", strings.Repeat("a1", 32), "https://192.168.1.226:3000", "sha256//AAAA",
  14. map[string]string{"arm64": "cafebabe"},
  15. reinstall.WanTargets{},
  16. )
  17. for _, want := range []string{
  18. `could not download the binary from $SERVER (curl)`,
  19. `could not download the binary from $SERVER (wget)`,
  20. `the .ipk package did not install`,
  21. `the .apk package did not install`,
  22. } {
  23. if !strings.Contains(s, want) {
  24. t.Errorf("el script no explica el fallo: %q", want)
  25. }
  26. }
  27. if err := exec.Command("sh", "-n", "-c", s).Run(); err != nil {
  28. t.Fatalf("script invalido: %v", err)
  29. }
  30. }