(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestConfig_validate(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | cfg Config |
| 15 | expectedErr string |
| 16 | }{ |
| 17 | { |
| 18 | name: "Default", |
| 19 | cfg: func() Config { |
| 20 | cfg := Config{} |
| 21 | cfg.RegisterFlagsAndApplyDefaults("", flag.NewFlagSet("", flag.ContinueOnError)) |
| 22 | cfg.PartitionsPerInstance = 2 |
| 23 | return cfg |
| 24 | }(), |
| 25 | }, |
| 26 | { |
| 27 | name: "ValidConfig", |
| 28 | cfg: Config{PartitionsPerInstance: 5}, |
| 29 | }, |
| 30 | { |
| 31 | name: "InvalidPartitionAssignment", |
| 32 | cfg: Config{}, |
| 33 | expectedErr: "at least one of AssignedPartitionsMap or PartitionsPerInstance must be set", |
| 34 | }, |
| 35 | } |
| 36 | for _, tc := range tests { |
| 37 | t.Run(tc.name, func(t *testing.T) { |
| 38 | err := tc.cfg.Validate() |
| 39 | if tc.expectedErr == "" { |
| 40 | require.NoError(t, err) |
| 41 | } else { |
| 42 | require.Error(t, err) |
| 43 | assert.Contains(t, err.Error(), tc.expectedErr) |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestConfig_partitionAssignment(t *testing.T) { |
| 50 | instanceID := "block-builder-42" |
nothing calls this directly
no test coverage detected