-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathproxy_backend_updater_test.go
More file actions
40 lines (34 loc) · 1.24 KB
/
Copy pathproxy_backend_updater_test.go
File metadata and controls
40 lines (34 loc) · 1.24 KB
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
package dewy
import (
"strings"
"testing"
"github.com/linyows/dewy/container"
)
// proxyBackendUpdater must satisfy container.BackendUpdater so it can be
// passed straight to runtime.Deploy.
func TestProxyBackendUpdaterImplementsInterface(t *testing.T) {
d := newPhaseTestDewy(t)
var _ container.BackendUpdater = (*proxyBackendUpdater)(d)
}
// AddBackend / RemoveBackend forward to addProxyBackend / removeProxyBackend.
// Without a real tcpProxy registered for the port, both methods surface an
// error path so we can assert the forwarding happened and the wiring is alive.
func TestProxyBackendUpdaterForwardsToDewy(t *testing.T) {
d := newPhaseTestDewy(t)
d.tcpProxies = nil // explicit empty
u := (*proxyBackendUpdater)(d)
err := u.AddBackend("localhost", 9001, 8080)
if err == nil {
t.Fatal("expected error when no proxy is configured for the port, got nil")
}
if !strings.Contains(err.Error(), "8080") {
t.Errorf("error %q should mention the missing proxy port 8080", err)
}
err = u.RemoveBackend("localhost", 9001, 8080)
if err == nil {
t.Fatal("expected error when no proxy is configured for the port, got nil")
}
if !strings.Contains(err.Error(), "8080") {
t.Errorf("error %q should mention the missing proxy port 8080", err)
}
}