mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-24 01:08:09 +08:00

Instead we're going to move back to standard exceptions. Using a custom Result class has created far far more problems - The Stacktraces aren't always right - Sometimes one forgets to check the Result error - All other exception throwing code needing to be converted to Results - Non idiomatic Dart code I think it's better to just go back to exceptions. They have their problems, but overall, I think it's a better approach.
57 lines
1.2 KiB
Dart
57 lines
1.2 KiB
Dart
/*
|
|
* SPDX-FileCopyrightText: 2019-2021 Vishesh Handa <me@vhanda.in>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import 'dart:convert';
|
|
|
|
import 'githost.dart';
|
|
import 'github.dart';
|
|
|
|
typedef JsonMap = Map<String, dynamic>;
|
|
typedef JsonList = List<JsonMap>;
|
|
|
|
class GitHubFake implements GitHost {
|
|
String data;
|
|
GitHubFake(this.data);
|
|
|
|
@override
|
|
void init(OAuthCallback oAuthCallback) {}
|
|
@override
|
|
Future<void> launchOAuthScreen() async {}
|
|
|
|
@override
|
|
Future<UserInfo> getUserInfo() async {
|
|
throw Exception("Not Implemented");
|
|
}
|
|
|
|
@override
|
|
Future<void> addDeployKey(String sshPublicKey, String repoFullName) async {
|
|
throw Exception("Not Implemented");
|
|
}
|
|
|
|
@override
|
|
Future<GitHostRepo> createRepo(String name) async {
|
|
throw Exception("Not Implemented");
|
|
}
|
|
|
|
@override
|
|
Future<GitHostRepo> getRepo(String name) async {
|
|
throw Exception("Not Implemented");
|
|
}
|
|
|
|
@override
|
|
Future<List<GitHostRepo>> listRepos() async {
|
|
List<dynamic> list = jsonDecode(data);
|
|
var repos = <GitHostRepo>[];
|
|
for (var d in list) {
|
|
var map = Map<String, dynamic>.from(d);
|
|
var repo = GitHub.repoFromJson(map);
|
|
repos.add(repo);
|
|
}
|
|
|
|
return repos;
|
|
}
|
|
}
|