From 2fd54849e0bf0670ac624abf20977c11f14209d5 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 19 Jun 2026 23:12:04 +1200 Subject: [PATCH] Prevent floating number precision issue Some test runs would cause runid to end up with a slightly differing values in the database which caused the tests to fail. An example of a failing test is when $runid was observed to be 153.425536363056, but in the database it is stored as '153.42553636305601'. This caused the Attribute to not be found causing some of the tests to fail. I see no need for a long fraction to be used, so truncate it. --- t/api/attribute-tests.t | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/api/attribute-tests.t b/t/api/attribute-tests.t index 8489f1a56bc..b30b58b3c94 100644 --- a/t/api/attribute-tests.t +++ b/t/api/attribute-tests.t @@ -4,8 +4,13 @@ use RT; use RT::Test nodata => 1, tests => 34; +# runid can't be an integer (why? not sure, maybe casting when stored in the database causes issues?) +# we need to ensure we don't have a long floating number number as there can be mismatching precision +# levels between Perl and the database. +my $runid = int(rand(200) * 100) / 100; -my $runid = rand(200); +# Make sure we always have a decimal, SQLite (at least) barfs if it is an integer. +if ($runid == int($runid)) { $runid += .1 }; my $attribute = "squelch-$runid";