Skip to content

Commit

Permalink
[chore] Relax field tag checks in Cloud Foundry Receiver tests (#37758)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

One option to help with
open-telemetry/opentelemetry-collector#12311.

We could also fix this after making that change, but I think the checks
now better reflect the intent of the test.
  • Loading branch information
evan-bradley authored Feb 6, 2025
1 parent 2a42490 commit 19bc7d6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion receiver/cloudfoundryreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cloudfoundryreceiver
import (
"path/filepath"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -167,5 +168,10 @@ func checkTypeFieldMatch(t *testing.T, fieldName string, localType reflect.Type,

require.True(t, localFieldPresent, "field %s present in local type", fieldName)
require.True(t, standardFieldPresent, "field %s present in standard type", fieldName)
require.Equal(t, localField.Tag, standardField.Tag, "field %s tag match", fieldName)

// Check that the mapstructure tag is not empty
require.GreaterOrEqual(t, len(strings.Split(localField.Tag.Get("mapstructure"), ",")), 1)

// Check that the configuration key names are the same, ignoring other tags like omitempty.
require.Equal(t, localField.Tag.Get("mapstructure")[0], standardField.Tag.Get("mapstructure")[0], "field %s tag match", fieldName)
}

0 comments on commit 19bc7d6

Please sign in to comment.