@@ -32,13 +32,18 @@ func Test_Metrics(t *testing.T) {
3232 MetricsHost : "localhost" ,
3333 }
3434
35- expectedMetrics := `zipserver_requests_total{host="localhost"} 1
36- zipserver_errors_total{host="localhost"} 0
37- zipserver_extracted_files_total{host="localhost"} 1
38- zipserver_copied_files_total{host="localhost"} 0
39- zipserver_deleted_files_total{host="localhost"} 0
40- zipserver_downloaded_bytes_total{host="localhost"} 7
41- zipserver_uploaded_bytes_total{host="localhost"} 0
42- `
43- assert .Equal (t , expectedMetrics , metrics .RenderMetrics (config ))
35+ rendered := metrics .RenderMetrics (config )
36+
37+ // Check counter metrics (exact values)
38+ assert .Contains (t , rendered , `zipserver_requests_total{host="localhost"} 1` )
39+ assert .Contains (t , rendered , `zipserver_errors_total{host="localhost"} 0` )
40+ assert .Contains (t , rendered , `zipserver_extracted_files_total{host="localhost"} 1` )
41+ assert .Contains (t , rendered , `zipserver_copied_files_total{host="localhost"} 0` )
42+ assert .Contains (t , rendered , `zipserver_deleted_files_total{host="localhost"} 0` )
43+ assert .Contains (t , rendered , `zipserver_downloaded_bytes_total{host="localhost"} 7` )
44+ assert .Contains (t , rendered , `zipserver_uploaded_bytes_total{host="localhost"} 0` )
45+
46+ // Check CPU metrics are present (values vary per run)
47+ assert .Contains (t , rendered , `zipserver_cpu_user_seconds_total{host="localhost"}` )
48+ assert .Contains (t , rendered , `zipserver_cpu_system_seconds_total{host="localhost"}` )
4449}
0 commit comments