Take the chat client's port from Run's caller (closes #4)
check / check (push) Successful in 1m8s
check / check (push) Successful in 1m8s
The test that runs the whole bot started its stand-in chat client on 5225, the port a real simplex-chat uses, so on a machine where one listens there the test would have sent it the bot's set-up commands. Run now takes the chat client's port: the run command passes bot.ChatPort (5225), and the test a port it found free. Model: opus-5-5
This commit is contained in:
@@ -52,9 +52,7 @@ func TestMain(m *testing.M) {
|
||||
// port it is given, on localhost, and answers the commands the bot
|
||||
// sends. SIGTERM ends it, as it ends the real client. Unlike the real
|
||||
// client, it also exits when the bot hangs up, so that it never
|
||||
// outlives a test run that was cut short. It takes port 5225, the chat
|
||||
// client's fixed port, so this test cannot run twice at once on one
|
||||
// machine.
|
||||
// outlives a test run that was cut short.
|
||||
func standIn() {
|
||||
arg := func(name string) string {
|
||||
return os.Args[slices.Index(os.Args, name)+1]
|
||||
@@ -142,6 +140,8 @@ func TestStopDuringRequest(t *testing.T) {
|
||||
t.Setenv("PATH", bin)
|
||||
|
||||
cfg := &config.Config{DataDir: t.TempDir(), Port: freePort(t), APIToken: credential}
|
||||
// Never bot.ChatPort: a real chat client may be listening there.
|
||||
chatPort := freePort(t)
|
||||
ctx, stop := context.WithCancel(t.Context())
|
||||
done := make(chan struct{})
|
||||
|
||||
@@ -150,7 +150,7 @@ func TestStopDuringRequest(t *testing.T) {
|
||||
go func() {
|
||||
defer close(done)
|
||||
|
||||
runErr = bot.Run(ctx, slog.New(slog.DiscardHandler), cfg)
|
||||
runErr = bot.Run(ctx, slog.New(slog.DiscardHandler), cfg, chatPort)
|
||||
}()
|
||||
|
||||
t.Cleanup(func() {
|
||||
|
||||
Reference in New Issue
Block a user