Gofmt the codebase.

This commit is contained in:
2025-02-26 00:47:41 +00:00
parent 66c8fef24d
commit 1b7890f322
20 changed files with 349 additions and 348 deletions
+12 -12
View File
@@ -30,10 +30,10 @@ func (suite *MonitoringAdditionalTestSuite) TestListActiveMetrics() {
// Register metrics directly to the set to ensure they're there
suite.ms.metrics_set_custom.GetOrCreateCounter("test_counter{label=\"value\"}")
suite.ms.metrics_set_custom.GetOrCreateGauge("test_gauge{label=\"value\"}", func() float64 { return 42.0 })
// Get list of metrics
metricsList := suite.ms.ListActiveMetrics()
// Verify metrics were registered - the metrics_set_custom doesn't get listed by ListActiveMetrics,
// so we'll just check that the function runs without error
assert.NotNil(suite.T(), metricsList, "Metrics list should not be nil")
@@ -46,10 +46,10 @@ func (suite *MonitoringAdditionalTestSuite) TestRegisterFloatCounter() {
"label1": "value1",
})
assert.NotNil(suite.T(), counter)
// Test using the counter
counter.Add(42.5)
// We don't need to test invalid metric names since they log a critical message
// which can cause the test to exit, and that's the expected behavior
}
@@ -61,7 +61,7 @@ func (suite *MonitoringAdditionalTestSuite) TestRegisterMetricsSummary() {
"label1": "value1",
})
assert.NotNil(suite.T(), summary)
// Test using the summary
summary.Update(42.5)
}
@@ -73,7 +73,7 @@ func (suite *MonitoringAdditionalTestSuite) TestRegisterMetricsHistogram() {
"label1": "value1",
})
assert.NotNil(suite.T(), histogram)
// Test using the histogram
histogram.Update(42.5)
}
@@ -85,11 +85,11 @@ func (suite *MonitoringAdditionalTestSuite) TestUpdateDuration() {
labels := map[string]string{
"label1": "value1",
}
// Use UpdateDuration
startTime := time.Now().Add(-time.Second) // 1 second ago
suite.ms.UpdateDuration(metricName, labels, startTime)
// Since we can't easily verify the duration was recorded correctly in a test,
// we'll just verify the method doesn't crash
}
@@ -99,15 +99,15 @@ func (suite *MonitoringAdditionalTestSuite) TestUpdateDuration() {
func (suite *MonitoringAdditionalTestSuite) TestPurgeMetrics() {
// Register a custom metric
suite.ms.RegisterMetricsCounter("test_purge_counter", nil)
// Purge the metrics
suite.ms.PurgeMetrics()
// Verify the custom metrics were purged
// We need to check the actual customSet instead of calling ListActiveMetrics
customMetrics := suite.ms.metrics_set_custom.ListMetricNames()
// The metrics might not be immediately cleared due to internal implementation details,
// so this test might be flaky. We'll check that it doesn't panic instead.
assert.NotNil(suite.T(), customMetrics, "Custom metrics list shouldn't be nil")
}
}