access-engine/cmd/flex-auth/main_test.go

27 lines
699 B
Go
Raw Normal View History

package main
2026-05-17 05:59:48 +02:00
import (
"os"
"os/exec"
2026-05-17 05:59:48 +02:00
"strings"
"testing"
)
// The retired binary must fail and name its replacement, whatever it is asked.
func TestRetiredBinaryNamesReplacement(t *testing.T) {
if os.Getenv("ACCESS_ENGINE_STUB_CHILD") == "1" {
main()
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestRetiredBinaryNamesReplacement", "serve", "--addr", "x")
cmd.Env = append(os.Environ(), "ACCESS_ENGINE_STUB_CHILD=1")
out, err := cmd.CombinedOutput()
exit, ok := err.(*exec.ExitError)
if !ok || exit.ExitCode() != 2 {
t.Fatalf("want exit 2, got %v", err)
}
if !strings.Contains(string(out), "renamed to access-engine") {
t.Fatalf("missing rename message: %s", out)
}
}