forked from charmbracelet/wishlist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
54 lines (47 loc) · 1.02 KB
/
config_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
44
45
46
47
48
49
50
51
52
53
54
package wishlist
import (
"testing"
"github.com/charmbracelet/wish"
"github.com/gliderlabs/ssh"
"github.com/stretchr/testify/require"
)
func TestEndpointValid(t *testing.T) {
t.Run("valid", func(t *testing.T) {
require.True(t, Endpoint{
Name: "test",
Address: "test",
}.Valid())
require.True(t, Endpoint{
Name: "test",
Middlewares: []wish.Middleware{
func(h ssh.Handler) ssh.Handler { return h },
},
}.Valid())
})
t.Run("no name", func(t *testing.T) {
require.False(t, Endpoint{
Name: "",
Address: "test",
}.Valid())
})
t.Run("no address or middleware", func(t *testing.T) {
require.False(t, Endpoint{
Name: "test",
}.Valid())
})
}
func TestShoudListen(t *testing.T) {
t.Run("true", func(t *testing.T) {
require.True(t, Endpoint{
Name: "test",
Middlewares: []wish.Middleware{
func(h ssh.Handler) ssh.Handler { return h },
},
}.ShouldListen())
})
t.Run("false", func(t *testing.T) {
require.False(t, Endpoint{
Name: "test",
}.ShouldListen())
})
}