fix(flutter/test): isVersionNewer date-style assertion was wrong
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user