Skip to content

Commit

Permalink
[mdatagen]: require.Emptyf on config diff (open-telemetry#11667)
Browse files Browse the repository at this point in the history
#### Description

Uses require.Emptyf on config diff instead of testing.Error with diff
not empty

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Nov 13, 2024
1 parent f4546bf commit 9b46957
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions cmd/mdatagen/internal/templates/config_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ func TestMetricsBuilderConfig(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := loadMetricsBuilderConfig(t, tt.name)
if diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(MetricConfig{}
{{- if .ResourceAttributes }}, ResourceAttributeConfig{}{{ end }})); diff != "" {
t.Errorf("Config mismatch (-expected +actual):\n%s", diff)
}
diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(MetricConfig{}
{{- if .ResourceAttributes }}, ResourceAttributeConfig{}{{ end }}))
require.Emptyf(t, diff, "Config mismatch (-expected +actual):\n%s", diff)
})
}
}
Expand Down Expand Up @@ -109,9 +108,8 @@ func TestResourceAttributesConfig(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := loadResourceAttributesConfig(t, tt.name)
if diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(ResourceAttributeConfig{})); diff != "" {
t.Errorf("Config mismatch (-expected +actual):\n%s", diff)
}
diff := cmp.Diff(tt.want, cfg, cmpopts.IgnoreUnexported(ResourceAttributeConfig{}))
require.Emptyf(t, diff, "Config mismatch (-expected +actual):\n%s", diff)
})
}
}
Expand Down

0 comments on commit 9b46957

Please sign in to comment.