An operator's DATA_LOCATION and BACKUP_LOCATION may name a subdivision
(ISO 3166-2, US-CA, DE-BY) besides the EU or a country. The app adds
"(EU)" to a member country and the country to a subdivision ("Germany
(EU)", "California, United States", "Bavaria, Germany (EU)"), in
English and German, and shows the most specific flag there is: a
subdivision's own where the flag package has one, else its country's.
Subdivision names come from Unicode CLDR 48.2 (tool/subdivision_names.py),
bundled with their licence, which the app registers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
61 lines
2.1 KiB
Dart
61 lines
2.1 KiB
Dart
import 'package:halkyon_base_server/base.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group("Where the operator says the instance's data is", () {
|
|
test("is a country's code or the European Union's", () {
|
|
expect(dataLocationFrom('CH'), 'CH');
|
|
expect(dataLocationFrom('EU'), 'EU');
|
|
});
|
|
|
|
test("is a subdivision's code (ISO 3166-2): a state, a canton, a "
|
|
'region', () {
|
|
expect(dataLocationFrom('US-CA'), 'US-CA');
|
|
expect(dataLocationFrom('DE-BY'), 'DE-BY');
|
|
expect(dataLocationFrom('GB-SCT'), 'GB-SCT');
|
|
// Some countries number theirs.
|
|
expect(dataLocationFrom('FR-75'), 'FR-75');
|
|
expect(dataLocationFrom('JP-13'), 'JP-13');
|
|
});
|
|
|
|
test('is read in either case, around spaces', () {
|
|
expect(dataLocationFrom(' ch '), 'CH');
|
|
expect(dataLocationFrom(' us-ca '), 'US-CA');
|
|
});
|
|
|
|
test('is nothing where it is unset, empty or no code', () {
|
|
expect(dataLocationFrom(null), isNull);
|
|
expect(dataLocationFrom(''), isNull);
|
|
expect(dataLocationFrom('Switzerland'), isNull);
|
|
expect(dataLocationFrom('C1'), isNull);
|
|
expect(dataLocationFrom('US-'), isNull);
|
|
expect(dataLocationFrom('US-CALI'), isNull);
|
|
expect(dataLocationFrom('US CA'), isNull);
|
|
expect(dataLocationFrom('USA-CA'), isNull);
|
|
expect(dataLocationFrom('EU-DE'), isNull);
|
|
});
|
|
|
|
test('is never "none": the data is somewhere', () {
|
|
expect(dataLocationFrom('none'), isNull);
|
|
});
|
|
});
|
|
|
|
group('Where the operator says its backups are', () {
|
|
test("is a country's code, a subdivision's or the European Union's", () {
|
|
expect(backupLocationFrom('ch'), 'CH');
|
|
expect(backupLocationFrom('fi-18'), 'FI-18');
|
|
expect(backupLocationFrom('EU'), 'EU');
|
|
});
|
|
|
|
test('may be none, in either case', () {
|
|
expect(backupLocationFrom('none'), noBackups);
|
|
expect(backupLocationFrom('NONE'), noBackups);
|
|
});
|
|
|
|
test('is nothing where it is unset, empty or no code', () {
|
|
expect(backupLocationFrom(null), isNull);
|
|
expect(backupLocationFrom(''), isNull);
|
|
expect(backupLocationFrom('Hetzner'), isNull);
|
|
});
|
|
});
|
|
}
|