Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bail fast if function returns error #4016

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/metrics/collectors/latency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestParseMessageWithValidInputs(t *testing.T) {
}
} else {
if err != nil {
t.Errorf("parseMessage returned an unexpected error: %v", err)
t.Fatalf("parseMessage returned an unexpected error: %v", err)
}
if actual != test.expected {
t.Errorf("parseMessage returned: %+v, expected: %+v", actual, test.expected)
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestCreateLatencyLabelValuesWithCorrectNumberOfLabels(t *testing.T) {
expected := []string{"upstream-1", "10.0.0.1", "200", "service-1", "ingress", "ingress-1", "default", "pod-1"}
actual, err := collector.createLatencyLabelValues(lm)
if err != nil {
t.Errorf("createLatencyLabelValues returned unexpected error: %v", err)
t.Fatalf("createLatencyLabelValues returned unexpected error: %v", err)
}
if !reflect.DeepEqual(expected, actual) {
t.Errorf("createLatencyLabelValues returned: %v, expected: %v", actual, expected)
Expand Down Expand Up @@ -184,7 +184,7 @@ func TestMetricsPublished(t *testing.T) {
// verify metrics for upstream-1 are correct
upstream1Metrics, ok := collector.metricsPublishedMap["upstream-1/10.0.0.0:80"]
if !ok {
t.Errorf("updateMetricsPublished did not add upstream-1 as key to map")
t.Fatal("updateMetricsPublished did not add upstream-1 as key to map")
}
if l := len(upstream1Metrics); l != 2 {
t.Errorf("updateMetricsPublished did not update upstream-1 map correctly, length is %d expected 2", l)
Expand All @@ -208,7 +208,7 @@ func TestMetricsPublished(t *testing.T) {
// verify metrics for upstream-2 are correct
upstream2Metrics, ok := collector.metricsPublishedMap["upstream-2/10.0.0.0:80"]
if !ok {
t.Errorf("updateMetricsPublished did not add upstream-2 as key to map")
t.Fatal("updateMetricsPublished did not add upstream-2 as key to map")
}
if l := len(upstream2Metrics); l != 1 {
t.Errorf("updateMetricsPublished did not update upstream-2 map correctly, length is %d expected 1", l)
Expand Down