CI / changes (push) Successful in 5s
CI / openapi (push) Has been skipped
CI / go (push) Successful in 25s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, , evobgp-web) (push) Successful in 1m9s
CI / docker-web (deploy/docker/evobgp-web/Dockerfile, evobgp-all, evobgp-web-all) (push) Successful in 1m2s
CI / docker-bird (push) Has been skipped
CI / bird2 (push) Successful in 14s
CI / docker-go (deploy/docker/evobgp-agent/Dockerfile, , evobgp-agent) (push) Successful in 1m1s
CI / docker-go (evobgp-all, 1, deploy/docker/gobinary/Dockerfile, , evobgp-all) (push) Successful in 1m24s
CI / docker-go (evobgp-api, 1, deploy/docker/gobinary/Dockerfile, , evobgp-api) (push) Successful in 1m28s
CI / docker-go (evobgp-deploy, 0, deploy/docker/gobinary/Dockerfile, , evobgp-deploy) (push) Successful in 1m21s
CI / docker-go (evobgp-ingest, 0, deploy/docker/gobinary/Dockerfile, , evobgp-ingest) (push) Successful in 1m24s
CI / docker-go (evobgp-node, 0, deploy/docker/gobinary/Dockerfile, , evobgp-node) (push) Successful in 1m10s
CI / docker-go (evobgp-render, 0, deploy/docker/gobinary/Dockerfile, , evobgp-render) (push) Successful in 1m19s
CI / docker-go (evobgp-scheduler, 0, deploy/docker/gobinary/Dockerfile, , evobgp-scheduler) (push) Has been cancelled
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package store
|
|
|
|
import "testing"
|
|
|
|
func TestEffectivePeerEnabledOnCreate(t *testing.T) {
|
|
if !EffectivePeerEnabledOnCreate(false, "") {
|
|
t.Fatal("omitted enabled (false) + empty session should default to enabled")
|
|
}
|
|
if !EffectivePeerEnabledOnCreate(true, "") {
|
|
t.Fatal("explicit true")
|
|
}
|
|
if !EffectivePeerEnabledOnCreate(true, "down") {
|
|
t.Fatal("true with session")
|
|
}
|
|
if EffectivePeerEnabledOnCreate(false, "Idle") {
|
|
t.Fatal("false with non-empty session should stay disabled")
|
|
}
|
|
}
|
|
|
|
func TestParsePeerNeighbor(t *testing.T) {
|
|
tests := []struct {
|
|
in string
|
|
want string
|
|
wantOK bool
|
|
}{
|
|
{"192.168.0.2", "192.168.0.2", true},
|
|
{"192.168.0.2/32", "192.168.0.2", true},
|
|
{" 192.168.0.2/32 ", "192.168.0.2", true},
|
|
{"2001:db8::1", "2001:db8::1", true},
|
|
{"2001:db8::1/128", "2001:db8::1", true},
|
|
{"192.168.0.0/24", "", false},
|
|
{"not-an-ip", "", false},
|
|
{"", "", false},
|
|
}
|
|
for _, tt := range tests {
|
|
addr, ok := ParsePeerNeighbor(tt.in)
|
|
if ok != tt.wantOK {
|
|
t.Errorf("ParsePeerNeighbor(%q) ok=%v want %v", tt.in, ok, tt.wantOK)
|
|
continue
|
|
}
|
|
if !tt.wantOK {
|
|
continue
|
|
}
|
|
if got := addr.String(); got != tt.want {
|
|
t.Errorf("ParsePeerNeighbor(%q) = %q want %q", tt.in, got, tt.want)
|
|
}
|
|
}
|
|
}
|