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); }); }); }