(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestDetectMode(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | m map[string]interface{} |
| 17 | flagOverride string |
| 18 | expected string |
| 19 | }{ |
| 20 | { |
| 21 | name: "target all is monolithic", |
| 22 | m: map[string]interface{}{"target": "all"}, |
| 23 | expected: modeMonolithic, |
| 24 | }, |
| 25 | { |
| 26 | name: "no target field is monolithic", |
| 27 | m: map[string]interface{}{}, |
| 28 | expected: modeMonolithic, |
| 29 | }, |
| 30 | { |
| 31 | name: "empty target is monolithic", |
| 32 | m: map[string]interface{}{"target": ""}, |
| 33 | expected: modeMonolithic, |
| 34 | }, |
| 35 | // Empty-target key removal is asserted separately below. |
| 36 | { |
| 37 | name: "distributor target is microservices", |
| 38 | m: map[string]interface{}{"target": "distributor"}, |
| 39 | expected: modeMicroservices, |
| 40 | }, |
| 41 | { |
| 42 | name: "query-frontend target is microservices", |
| 43 | m: map[string]interface{}{"target": "query-frontend"}, |
| 44 | expected: modeMicroservices, |
| 45 | }, |
| 46 | { |
| 47 | name: "flag override takes precedence", |
| 48 | m: map[string]interface{}{"target": "all"}, |
| 49 | flagOverride: modeMicroservices, |
| 50 | expected: modeMicroservices, |
| 51 | }, |
| 52 | } |
| 53 | |
| 54 | for _, tt := range tests { |
| 55 | t.Run(tt.name, func(t *testing.T) { |
| 56 | result := detectMode(tt.m, tt.flagOverride, new([]string)) |
| 57 | assert.Equal(t, tt.expected, result) |
| 58 | }) |
| 59 | } |
| 60 | |
| 61 | t.Run("scalable-single-binary is rewritten to all with warning", func(t *testing.T) { |
| 62 | m := map[string]interface{}{"target": "scalable-single-binary"} |
| 63 | var warnings []string |
| 64 | result := detectMode(m, "", &warnings) |
| 65 | assert.Equal(t, modeMonolithic, result) |
| 66 | assert.Equal(t, "all", m["target"]) |
| 67 | require.Len(t, warnings, 1) |
| 68 | assert.Contains(t, warnings[0], "scalable-single-binary") |
| 69 | assert.Contains(t, warnings[0], "removed in Tempo 3.0") |
| 70 | }) |
nothing calls this directly
no test coverage detected