Skip to content

Commit

Permalink
fix: templateName error in mapping test and refractor mapping.go
Browse files Browse the repository at this point in the history
Signed-off-by: Saumya Shah <[email protected]>
  • Loading branch information
Saumya40-codes committed Oct 12, 2024
1 parent 75dc329 commit 59885e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions plugin/storage/es/mappings/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ func MappingTypeFromString(val string) (MappingType, error) {
// GetMapping returns the rendered mapping based on elasticsearch version
func (mb *MappingBuilder) GetMapping(mappingType MappingType) (string, error) {
templateOpts := mb.getMappingTemplateOptions(mappingType)
var version string
var version int
switch mb.EsVersion {
case 8:
version = "-8"
version = 8
case 7:
version = "-7"
version = 7
default:
version = "-6"
version = 6
}

return mb.renderMapping(fmt.Sprintf("%s-%d.json", mappingType, version), templateOpts)
Expand Down
4 changes: 3 additions & 1 deletion plugin/storage/es/mappings/mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func TestMappingBuilderGetMapping(t *testing.T) {
{mapping: DependenciesMapping, esVersion: 6},
}
for _, tt := range tests {
templateName := tt.mapping.String()

t.Run(tt.mapping.String(), func(t *testing.T) {
defaultOpts := func(p int64) config.IndexOptions {
return config.IndexOptions{
Expand Down Expand Up @@ -162,7 +164,7 @@ func TestMappingBuilderFixMapping(t *testing.T) {
UseILM: true,
ILMPolicyName: "jaeger-test-policy",
}
_, err := mappingBuilder.renderMapping("test", mappingBuilder.getMappingTemplateOptions("test"))
_, err := mappingBuilder.renderMapping("test", mappingBuilder.getMappingTemplateOptions(SpanMapping))
if test.err != "" {
require.EqualError(t, err, test.err)
} else {
Expand Down

0 comments on commit 59885e9

Please sign in to comment.