Skip to content

Commit dda5003

Browse files
committed
test(agent): assert session.Exit(1) in TestShell_StartPtyError
Verify the behaviour the test documents but did not check: a failed startPty must call session.Exit once with code 1.
1 parent faf9c6a commit dda5003

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

agent/server/modes/host/sessioner_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ func TestShell_StartPtyError(t *testing.T) {
193193
assert.NotNil(t, retErr, "Shell() must return a non-nil error when startPty fails")
194194
assert.True(t, strings.Contains(retErr.Error(), "pty"), "error should mention 'pty', got: %s", retErr.Error())
195195
assert.Empty(t, s.cmds, "s.cmds must be empty — the session must not have been registered")
196+
assert.Equal(t, int32(1), atomic.LoadInt32(&sess.exitCalled), "session.Exit must be called once")
197+
assert.Equal(t, int32(1), atomic.LoadInt32(&sess.exitCode), "session.Exit must be called with code 1")
196198
}
197199

198200
// TestExec_InitPtyError verifies that Exec() with sIsPty=true does NOT panic and

0 commit comments

Comments
 (0)