(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestConfigErrors(t *testing.T) { |
| 48 | globalCfg := oc.Global{ |
| 49 | Config: oc.GlobalConfig{ |
| 50 | As: 1, |
| 51 | RouterId: netip.MustParseAddr("1.1.1.1"), |
| 52 | Port: 11179, |
| 53 | }, |
| 54 | } |
| 55 | |
| 56 | for _, tt := range []struct { |
| 57 | name string |
| 58 | expectedErrors []string |
| 59 | cfg *oc.BgpConfigSet |
| 60 | }{ |
| 61 | { |
| 62 | name: "peer with a valid peer-group", |
| 63 | cfg: &oc.BgpConfigSet{ |
| 64 | Global: globalCfg, |
| 65 | Neighbors: []oc.Neighbor{ |
| 66 | { |
| 67 | Config: oc.NeighborConfig{ |
| 68 | PeerGroup: "router", |
| 69 | NeighborAddress: netip.MustParseAddr("1.1.1.2"), |
| 70 | }, |
| 71 | }, |
| 72 | }, |
| 73 | PeerGroups: []oc.PeerGroup{ |
| 74 | { |
| 75 | Config: oc.PeerGroupConfig{ |
| 76 | PeerGroupName: "router", |
| 77 | PeerAs: 2, |
| 78 | }, |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | }, |
| 83 | { |
| 84 | name: "peer without peer-group", |
| 85 | expectedErrors: []string{"Failed to add Peer"}, |
| 86 | cfg: &oc.BgpConfigSet{ |
| 87 | Global: globalCfg, |
| 88 | Neighbors: []oc.Neighbor{ |
| 89 | { |
| 90 | Config: oc.NeighborConfig{ |
| 91 | PeerGroup: "not-exists", |
| 92 | NeighborAddress: netip.MustParseAddr("1.1.1.2"), |
| 93 | }, |
| 94 | }, |
| 95 | }, |
| 96 | }, |
| 97 | }, |
| 98 | { |
| 99 | name: "policy without a set", |
| 100 | expectedErrors: []string{"failed to create routing policy", "failed to set policies"}, |
| 101 | cfg: &oc.BgpConfigSet{ |
| 102 | Global: globalCfg, |
| 103 | PolicyDefinitions: []oc.PolicyDefinition{ |
| 104 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…