Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit460b762

Browse files
committed
Add test for SSH env vars
1 parent5fc1d41 commit460b762

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎agent/agent_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,29 @@ func TestAgent(t *testing.T) {
252252
}
253253
})
254254

255+
t.Run("SSH connection env vars",func(t*testing.T) {
256+
t.Parallel()
257+
258+
// Note: the SSH_TTY environment variable should only be set for TTYs.
259+
// For some reason this test produces a TTY locally and a non-TTY in CI
260+
// so we don't test for the absence of SSH_TTY.
261+
for_,key:=range []string{"SSH_CONNECTION","SSH_CLIENT"} {
262+
key:=key
263+
t.Run(key,func(t*testing.T) {
264+
t.Parallel()
265+
266+
session:=setupSSHSession(t, agent.Metadata{})
267+
command:="sh -c 'echo $"+key+"'"
268+
ifruntime.GOOS=="windows" {
269+
command="cmd.exe /c echo %"+key+"%"
270+
}
271+
output,err:=session.Output(command)
272+
require.NoError(t,err)
273+
require.NotEmpty(t,strings.TrimSpace(string(output)))
274+
})
275+
}
276+
})
277+
255278
t.Run("StartupScript",func(t*testing.T) {
256279
t.Parallel()
257280
tempPath:=filepath.Join(t.TempDir(),"content.txt")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp