mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-23 00:27:12 +08:00
45 lines
1.0 KiB
Dart
45 lines
1.0 KiB
Dart
/*
|
|
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:path/path.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'package:git_setup/apis/githost_factory.dart';
|
|
import 'package:git_setup/apis/github.dart';
|
|
import 'lib.dart';
|
|
|
|
void main() {
|
|
setUpAll(gjSetupAllTests);
|
|
|
|
test('Parse json', () async {
|
|
var testDataPath = '';
|
|
|
|
var currentDir = Directory.current;
|
|
var folderName = basename(currentDir.path);
|
|
|
|
if (folderName == 'test') {
|
|
testDataPath = join(currentDir.path, 'apis/data/github.json');
|
|
} else {
|
|
testDataPath = join(currentDir.path, 'test/apis/data/github.json');
|
|
}
|
|
|
|
var jsonString = File(testDataPath).readAsStringSync();
|
|
|
|
List<dynamic> list = jsonDecode(jsonString);
|
|
var repos = <GitHostRepo>[];
|
|
for (var d in list) {
|
|
var map = Map<String, dynamic>.from(d);
|
|
var repo = GitHub.repoFromJson(map);
|
|
repos.add(repo);
|
|
}
|
|
|
|
expect(repos.length, 2);
|
|
});
|
|
}
|