47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package nsc
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestNSCSSHBootstrapLikelySucceeded(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
err := errors.New("wait: remote command exited without exit status or exit signal")
|
|
output := `
|
|
level=info msg="Runner registered successfully."
|
|
time="2026-03-19T11:29:49Z" level=info msg="Starting job"
|
|
time="2026-03-19T11:29:50Z" level=info msg="task 124 repo is hackclub/burrow"
|
|
`
|
|
|
|
if !nscSSHBootstrapLikelySucceeded(err, output) {
|
|
t.Fatal("expected handoff success heuristic to match")
|
|
}
|
|
}
|
|
|
|
func TestNSCSSHBootstrapLikelySucceededRejectsIncompleteOutput(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
err := errors.New("wait: remote command exited without exit status or exit signal")
|
|
output := `level=info msg="Runner registered successfully."`
|
|
|
|
if nscSSHBootstrapLikelySucceeded(err, output) {
|
|
t.Fatal("expected incomplete runner output to remain a failure")
|
|
}
|
|
}
|
|
|
|
func TestNSCSSHBootstrapLikelySucceededRejectsDifferentErrors(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
err := errors.New("exit status 1")
|
|
output := `
|
|
level=info msg="Runner registered successfully."
|
|
time="2026-03-19T11:29:49Z" level=info msg="Starting job"
|
|
time="2026-03-19T11:29:50Z" level=info msg="task 124 repo is hackclub/burrow"
|
|
`
|
|
|
|
if nscSSHBootstrapLikelySucceeded(err, output) {
|
|
t.Fatal("expected unrelated nsc ssh errors to remain failures")
|
|
}
|
|
}
|