From f6e27cd39a0ac62b3f217ad7b0c3d2b91b3048bd Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 10 May 2026 20:09:53 -0400 Subject: [PATCH] fix(flutter/test): isVersionNewer date-style assertion was wrong MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pub_semver is permissive with leading zeros — '2026.05.10' parses as 2026.5.10, so date-style tags get strict semver ordering, not the unparseable-fallback path. The test was asserting "any difference = newer" for date strings, which is incorrect; the actual behavior (and the right behavior) is proper ordering. Split the test group into two: - date-style (parses as semver): newer/older/equal assertions - truly unparseable (e.g. branch names like 'main', 'dev'): the fallback's "any difference = newer" semantics still apply Implementation in client_update_provider.dart unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../update/client_update_provider_test.dart | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/flutter_client/test/update/client_update_provider_test.dart b/flutter_client/test/update/client_update_provider_test.dart index 1ed1f679..3c362944 100644 --- a/flutter_client/test/update/client_update_provider_test.dart +++ b/flutter_client/test/update/client_update_provider_test.dart @@ -31,18 +31,31 @@ void main() { }); }); - group('isVersionNewer (non-semver fallback)', () { - test('different strings → newer', () { - // Date-tag-style versions don't parse as semver; falls back to - // string inequality. Operator can dismiss if the comparison is - // wrong (the alternative — silent skip — would mean operators - // never see updates). + group('isVersionNewer (date-style versions parse as semver)', () { + // pub_semver is permissive with leading zeros — '2026.05.10' + // parses as 2026.5.10. So date-style tags get strict ordering, + // not the unparseable-fallback path. + test('newer date → newer', () { expect(isVersionNewer('2026.05.10', '2026.05.09'), isTrue); - expect(isVersionNewer('2026.05.09', '2026.05.10'), isTrue); }); - - test('equal strings → not newer', () { + test('older date → not newer', () { + expect(isVersionNewer('2026.05.09', '2026.05.10'), isFalse); + }); + test('equal date → not newer', () { expect(isVersionNewer('2026.05.10', '2026.05.10'), isFalse); }); }); + + group('isVersionNewer (truly non-semver fallback)', () { + // Branch-name-style strings (no version structure) hit the + // try/catch fallback. Any string difference reads as "newer" so + // operators see _something_ rather than silently miss updates. + test('different unparseable strings → newer', () { + expect(isVersionNewer('main', 'dev'), isTrue); + expect(isVersionNewer('dev', 'main'), isTrue); + }); + test('equal unparseable strings → not newer', () { + expect(isVersionNewer('main', 'main'), isFalse); + }); + }); }