Skip to content

Commit e024871

Browse files
committed
Fix the NaN test
Signed-off-by: Felix Yuan <[email protected]>
1 parent fdd5e21 commit e024871

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

collector/pg_xid_test.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ func TestPgXidCollector(t *testing.T) {
6565
}
6666
}
6767

68-
// This test is turned off for now
69-
// Because convey cannot compare NaN
70-
func xTestPgNanCollector(t *testing.T) {
68+
func TestPgNanCollector(t *testing.T) {
7169
db, mock, err := sqlmock.New()
7270
if err != nil {
7371
t.Fatalf("Error opening a stub db connection: %s", err)
@@ -101,7 +99,12 @@ func xTestPgNanCollector(t *testing.T) {
10199
convey.Convey("Metrics comparison", t, func() {
102100
for _, expect := range expected {
103101
m := readMetric(<-ch)
104-
convey.So(expect, convey.ShouldResemble, m)
102+
if math.IsNaN(expect.value) {
103+
// Assume the rest of it looks fine since the above test should properly exercise it
104+
convey.So(math.IsNaN(m.value), convey.ShouldBeTrue)
105+
} else {
106+
convey.So(expect, convey.ShouldResemble, m)
107+
}
105108
}
106109
})
107110
if err := mock.ExpectationsWereMet(); err != nil {

0 commit comments

Comments
 (0)