feat: enhance evobgp with new command-line tools for bundle management, including pull, verify, and apply functionalities. Update go.mod to include necessary dependencies and complete todos in architecture plan for improved observability and deployment practices.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package birdfmt
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//go:embed testdata/golden/main_bird_skeleton.golden
|
||||
var goldenMainBirdSkeleton string
|
||||
|
||||
func TestRenderMainBirdConf_Golden(t *testing.T) {
|
||||
got, err := RenderMainBirdConf(MainBirdConfOptions{
|
||||
RouterID: "192.0.2.1",
|
||||
Includes: StandardIncludeFragments(),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := strings.TrimSuffix(goldenMainBirdSkeleton, "\n")
|
||||
got = strings.TrimSuffix(got, "\n")
|
||||
if got != want {
|
||||
t.Fatalf("golden mismatch\n--- got ---\n%s\n--- want ---\n%s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderMainBirdConf_Preamble(t *testing.T) {
|
||||
got, err := RenderMainBirdConf(MainBirdConfOptions{
|
||||
RouterID: "192.0.2.1",
|
||||
Includes: nil,
|
||||
Preamble: "operator note\n# already commented",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.HasPrefix(got, "# operator note\n") {
|
||||
t.Fatalf("expected preamble prefix, got:\n%s", got)
|
||||
}
|
||||
if !strings.Contains(got, "# # already commented") {
|
||||
t.Fatal(got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderMainBirdConf_Errors(t *testing.T) {
|
||||
_, err := RenderMainBirdConf(MainBirdConfOptions{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for empty router id")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFragmentIncludePath(t *testing.T) {
|
||||
if p := FragmentIncludePath(FragmentPrefixesV4); p != "bird.d/evobgp_prefixes_v4.conf" {
|
||||
t.Fatal(p)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user