MCPcopy
hub / github.com/grafana/tempo / TestConfig_validate

Function TestConfig_validate

modules/blockbuilder/config_test.go:11–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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
49func TestConfig_partitionAssignment(t *testing.T) {
50 instanceID := "block-builder-42"

Callers

nothing calls this directly

Calls 4

ValidateMethod · 0.65
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected