Conversation
d5437cf to
d9c2e25
Compare
|
I can review it tomorrow or on Thursday. |
|
I'll squash down with DCO before merge |
ArthurSens
left a comment
There was a problem hiding this comment.
Thanks, just one comment and it should be good to go!
| - predeclared | ||
| - revive | ||
| - sloglint | ||
| - testifylint |
There was a problem hiding this comment.
Our golangci-lint configuration is synchronized with prometheus/prometheus (See #36)
So whatever changes you're making, it will be reverted 😬
There was a problem hiding this comment.
ok well I guess that's fine, it'll pass :)
|
Ah, I was about to merge #35 and realized it will create merge conflicts. Do you have a preferred order to merge these two? |
|
go do yours first |
There was a problem hiding this comment.
Pull Request Overview
This PR removes the use of the testify library by replacing require assertions with standard testing idioms and cleans up the module dependency on testify.
- Tests now use inline
ifchecks witht.Errorfinstead ofrequire.*. - Added
stringsimport for manualContainschecks. - Updated
go.modto drop thetestifyrequirement.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| normalize_label_test.go | Removed testify/require, replaced with manual if + t.Errorf |
| metric_namer_test.go | Ditto for require.Equal and require.Contains, added strings |
| go.mod | Removed github.com/stretchr/testify from require block |
Comments suppressed due to low confidence (1)
normalize_label_test.go:44
- [nitpick] The inline
ifchecks for equality are duplicated across tests; consider extracting a small helper (witht.Helper()) to reduce repetition and improve readability.
if utf8Allowed {
aknuds1
left a comment
There was a problem hiding this comment.
Generally LGTM, but please see my question.
Fixes #37 Signed-off-by: Owen Williams <owen.williams@grafana.com>
bb7c828 to
70ddaf5
Compare
pellared
left a comment
There was a problem hiding this comment.
Minor nit comments. Thanks
| // Build metric name using MetricNamer | ||
| gotMetricName := tt.namer.Build(tt.metric) | ||
| require.Equal(t, tt.expectedMetricName, gotMetricName) | ||
| if tt.expectedMetricName != gotMetricName { |
There was a problem hiding this comment.
nit: you can rename expected to want
| gotMetricName := tt.namer.Build(tt.metric) | ||
| require.Equal(t, tt.expectedMetricName, gotMetricName) | ||
| if tt.expectedMetricName != gotMetricName { | ||
| t.Errorf("namer.Build(%v), got %q, want %q", tt.metric, gotMetricName, tt.expectedMetricName) |
There was a problem hiding this comment.
| t.Errorf("namer.Build(%v), got %q, want %q", tt.metric, gotMetricName, tt.expectedMetricName) | |
| t.Errorf("namer.Build(%q) = %q, want %q", tt.metric, gotMetricName, tt.expectedMetricName) |
| gotUnitName := unitNamer.Build(tt.metric.Unit) | ||
| require.Equal(t, tt.expectedUnitName, gotUnitName) | ||
| if tt.expectedUnitName != gotUnitName { | ||
| t.Errorf("unitNamer.Build(%q), got %q, want %q", tt.metric.Unit, gotUnitName, tt.expectedUnitName) |
There was a problem hiding this comment.
| t.Errorf("unitNamer.Build(%q), got %q, want %q", tt.metric.Unit, gotUnitName, tt.expectedUnitName) | |
| t.Errorf("unitNamer.Build(%q) = %q, want %q", tt.metric.Unit, gotUnitName, tt.expectedUnitName) |
| require.Contains(t, gotMetricName, gotUnitName, | ||
| "Metric name '%s' should contain unit name '%s' when WithMetricSuffixes=true", | ||
| gotMetricName, gotUnitName) | ||
| if !strings.Contains(gotMetricName, gotUnitName) { |
There was a problem hiding this comment.
We can simply add && !strings.Contains(gotMetricName, gotUnitName) to line 1119
I also think that gotUnitName != "" can be omitted.
Then we would have
if tt.namer.WithMetricSuffixes && !strings.Contains(gotMetricName, gotUnitName) {| "Metric name '%s' should contain unit name '%s' when WithMetricSuffixes=true", | ||
| gotMetricName, gotUnitName) | ||
| if !strings.Contains(gotMetricName, gotUnitName) { | ||
| t.Errorf("Metric name '%q' should contain unit name '%s' when WithMetricSuffixes=true", gotMetricName, gotUnitName) |
There was a problem hiding this comment.
| t.Errorf("Metric name '%q' should contain unit name '%s' when WithMetricSuffixes=true", gotMetricName, gotUnitName) | |
| t.Errorf("Metric name %q should contain unit name %q when WithMetricSuffixes=true", gotMetricName, gotUnitName) |
| if utf8Allowed { | ||
| require.Equal(t, test.label, result) | ||
| if test.label != result { | ||
| t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.label) |
There was a problem hiding this comment.
| t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.label) | |
| t.Errorf("labelNamer.Build(%q) = %q, want %q", test.label, result, test.label) |
| } else { | ||
| require.Equal(t, test.expected, result) | ||
| if test.expected != result { | ||
| t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.expected) |
There was a problem hiding this comment.
| t.Errorf("labelNamer.Build(%q), got %q, want %q", test.label, result, test.expected) | |
| t.Errorf("labelNamer.Build(%q) = %q, want %q", test.label, result, test.expected) |
Fixes #37