forked from ContainerSSH/libcontainerssh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e_backend_test.go
43 lines (37 loc) · 936 Bytes
/
e2e_backend_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package libcontainerssh_test
import (
"fmt"
"testing"
"go.containerssh.io/libcontainerssh/config"
)
// TestBackends tests all possible backends for basic functionality.
func TestBackends(t *testing.T) {
for _, backend := range config.BackendValues() {
t.Run(
fmt.Sprintf("backend=%s", backend),
func(t *testing.T) {
testBackend(NewT(t), backend)
},
)
}
}
// testBackend tests a single backend.
func testBackend(t T, backend config.Backend) {
t.ConfigureBackend(backend)
t.StartContainerSSH()
t.LoginViaSSH()
t.Run("CommandExecution", func(t T) {
t.StartSessionChannel()
t.RequestCommandExecution("echo 'Hello world!' && sleep 3")
t.AssertStdoutHas("Hello world!")
t.CloseChannel()
})
t.Run("Shell", func(t T) {
t.StartSessionChannel()
t.RequestShell()
t.SendStdin("echo 'Hello world!' && sleep 3\n")
t.AssertStdoutHas("Hello world!")
t.SendStdin("exit\n")
t.CloseChannel()
})
}