24 lines
593 B
Go
24 lines
593 B
Go
package messenger
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os/exec"
|
|
"testing"
|
|
)
|
|
|
|
func TestTransformFailureClassification(t *testing.T) {
|
|
for _, c := range []struct {
|
|
command string
|
|
invalid bool
|
|
}{{"exit 65", true}, {"exit 2", false}, {"kill -KILL $$", false}} {
|
|
e := exec.Command("sh", "-c", c.command).Run()
|
|
if errors.Is(classifyTransformFailure(nil, e), ErrInvalidImage) != c.invalid {
|
|
t.Fatalf("misclassified encoder termination %q", c.command)
|
|
}
|
|
}
|
|
if !errors.Is(classifyTransformFailure(context.DeadlineExceeded, nil), context.DeadlineExceeded) {
|
|
t.Fatal("deadline lost")
|
|
}
|
|
}
|