35 lines
860 B
Go
35 lines
860 B
Go
package birdfmt
|
|
|
|
import (
|
|
_ "embed"
|
|
"net/netip"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
//go:embed testdata/golden/static_ipv4_small.golden
|
|
var goldenStaticIPv4Small string
|
|
|
|
func TestRenderStaticIPv4Protocol_Golden(t *testing.T) {
|
|
p1 := netip.MustParsePrefix("203.0.113.0/24")
|
|
p2 := netip.MustParsePrefix("198.51.100.0/24")
|
|
// duplicate to assert dedup
|
|
got := RenderStaticIPv4Protocol("evobgp_test", []netip.Prefix{p1, p2, p1})
|
|
|
|
want := strings.TrimSuffix(goldenStaticIPv4Small, "\n")
|
|
got = strings.TrimSuffix(got, "\n")
|
|
if got != want {
|
|
t.Fatalf("golden mismatch\n--- got ---\n%s\n--- want ---\n%s", got, want)
|
|
}
|
|
}
|
|
|
|
func TestRenderStaticIPv4Protocol_Empty(t *testing.T) {
|
|
got := RenderStaticIPv4Protocol("evobgp_empty", nil)
|
|
if !strings.Contains(got, "protocol static evobgp_empty") {
|
|
t.Fatal(got)
|
|
}
|
|
if !strings.Contains(got, "ipv4") {
|
|
t.Fatal(got)
|
|
}
|
|
}
|