You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dateKeys-dart/test/errors_spec_test.dart

49 lines
1.7 KiB

// The catalogue matches spec §69 exactly, in order, as TestCatalogueMatchesSpec
// of datekeys-go. The spec is read from the Go repository next to this one, at
// the commit that testdata/SOURCE.json pins, the one testdata/ was synced
// from, so that uncommitted changes there never count and a version not yet
// tagged can be read.
@TestOn('vm')
library;
import 'dart:convert';
import 'dart:io';
import 'package:datekeys/datekeys.dart';
import 'package:test/test.dart';
import '../tool/sync_testdata.dart' as testdata;
void main() {
final repo = Directory('../datekeys-go');
test(
'the catalogue is the list of ERR_ lines of spec §69, in order',
() {
final commit = testdata.check(Directory.current).commit;
final path =
'$commit:spec/DateKeys_Protocol_Specification_v$specVersion.md';
final r = Process.runSync(
'git',
['-C', repo.path, 'show', path],
stdoutEncoding: utf8,
stderrEncoding: utf8,
);
expect(r.exitCode, 0, reason: '${r.stderr}');
final spec = r.stdout as String;
final start = spec.indexOf('## 69. Errores normativos');
final end = spec.indexOf('## 70.');
expect(start, isNonNegative, reason: 'section 69 not found');
expect(end, greaterThan(start), reason: 'section 70 not found');
final want = [
for (final line in spec.substring(start, end).split('\n'))
if (line.trim().startsWith('ERR_')) line.trim(),
];
expect(want, isNotEmpty);
expect([for (final c in ErrorCode.values) c.code], want);
},
skip: repo.existsSync()
? false
: '../datekeys-go is missing: the spec is read from it',
);
}

Powered by TurnKey Linux.