platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
49
selective-vpn-api/app/transport_client_iface_test.go
Normal file
49
selective-vpn-api/app/transport_client_iface_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package app
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeTransportClientsStateSetsIfaceID(t *testing.T) {
|
||||
st := transportClientsState{
|
||||
Version: transportStateVersion,
|
||||
Items: []TransportClient{
|
||||
{ID: "A", Kind: TransportClientSingBox, IfaceID: ""},
|
||||
{ID: "B", Kind: TransportClientDNSTT, IfaceID: "Lab Net"},
|
||||
},
|
||||
}
|
||||
|
||||
norm, changed := normalizeTransportClientsState(st, false)
|
||||
if !changed {
|
||||
t.Fatalf("expected normalize change for iface_id")
|
||||
}
|
||||
if len(norm.Items) != 2 {
|
||||
t.Fatalf("unexpected items count: %d", len(norm.Items))
|
||||
}
|
||||
if norm.Items[0].ID != "a" || norm.Items[0].IfaceID != transportDefaultIfaceID {
|
||||
t.Fatalf("unexpected normalized first item: %#v", norm.Items[0])
|
||||
}
|
||||
if norm.Items[1].ID != "b" || norm.Items[1].IfaceID != "lab-net" {
|
||||
t.Fatalf("unexpected normalized second item: %#v", norm.Items[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeTransportClientsStateKeepsExplicitRoutingTable(t *testing.T) {
|
||||
st := transportClientsState{
|
||||
Version: transportStateVersion,
|
||||
Items: []TransportClient{
|
||||
{
|
||||
ID: "A",
|
||||
Kind: TransportClientSingBox,
|
||||
IfaceID: "edge-lab",
|
||||
RoutingTable: "custom-edge-table",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
norm, _ := normalizeTransportClientsState(st, false)
|
||||
if len(norm.Items) != 1 {
|
||||
t.Fatalf("unexpected items count: %d", len(norm.Items))
|
||||
}
|
||||
if got := norm.Items[0].RoutingTable; got != "agvpn_custom_edge_table" {
|
||||
t.Fatalf("unexpected routing table: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user