diff --git a/plugin/storage/es/mappings/mapping_test.go b/plugin/storage/es/mappings/mapping_test.go index 33cfb00e53c..1d0f4372fe5 100644 --- a/plugin/storage/es/mappings/mapping_test.go +++ b/plugin/storage/es/mappings/mapping_test.go @@ -80,6 +80,32 @@ func TestMappingBuilderGetMapping(t *testing.T) { } } +func TestMappingTypeFromString(t *testing.T) { + tests := []struct { + input string + expected MappingType + hasError bool + }{ + {"jaeger-span", SpanMapping, false}, + {"jaeger-service", ServiceMapping, false}, + {"jaeger-dependencies", DependenciesMapping, false}, + {"jaeger-sampling", SamplingMapping, false}, + {"invalid", MappingType(-1), true}, + } + + for _, tt := range tests { + t.Run(tt.input, func(t *testing.T) { + result, err := MappingTypeFromString(tt.input) + if tt.hasError { + assert.Error(t, err) + } else { + assert.NoError(t, err) + assert.Equal(t, tt.expected, result) + } + }) + } +} + func TestMappingBuilderLoadMapping(t *testing.T) { tests := []struct { name string