Files
Vishesh Handa 657721adc6 Update dart-git and stop using the Result class
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.
2023-11-24 14:03:30 +01:00

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