| 48 | } |
| 49 | |
| 50 | func TestAdvancedOptionsValidate(t *testing.T) { |
| 51 | t.Parallel() |
| 52 | cases := []struct { |
| 53 | name string |
| 54 | opts AdvancedOptions |
| 55 | wantErr bool |
| 56 | }{ |
| 57 | {name: "empty strategy is the default", opts: AdvancedOptions{}, wantErr: false}, |
| 58 | {name: "first-parent accepted", opts: AdvancedOptions{BootstrapStrategy: BootstrapStrategyFirstParent}, wantErr: false}, |
| 59 | {name: "topo accepted", opts: AdvancedOptions{BootstrapStrategy: BootstrapStrategyTopo}, wantErr: false}, |
| 60 | {name: "typo rejected at API edge", opts: AdvancedOptions{BootstrapStrategy: "topographic"}, wantErr: true}, |
| 61 | {name: "case-sensitive: TOPO is not topo", opts: AdvancedOptions{BootstrapStrategy: "TOPO"}, wantErr: true}, |
| 62 | } |
| 63 | for _, c := range cases { |
| 64 | t.Run(c.name, func(t *testing.T) { |
| 65 | t.Parallel() |
| 66 | err := c.opts.Validate() |
| 67 | if (err != nil) != c.wantErr { |
| 68 | t.Errorf("Validate() err=%v, wantErr=%v", err, c.wantErr) |
| 69 | } |
| 70 | }) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func TestClientRejectsUnknownStrategyBeforeIO(t *testing.T) { |
| 75 | t.Parallel() |