37 lines
1.0 KiB
Dart
37 lines
1.0 KiB
Dart
import 'package:pipelines_app/core/api_gateway.dart';
|
|
|
|
import 'chat_thread_fixtures.dart';
|
|
|
|
class TasksGateway extends FakeChatGateway {
|
|
TasksGateway() {
|
|
history = (_) async => chatPage([]);
|
|
}
|
|
|
|
Future<JsonMap> Function(JsonMap)? shells;
|
|
Future<JsonMap> Function(JsonMap)? output;
|
|
|
|
@override
|
|
Future<JsonMap> call(String type, [JsonMap fields = const {}]) {
|
|
if (type == 'chat_shells' || type == 'chat_shell_output') {
|
|
calls.add((type: type, fields: fields));
|
|
if (type == 'chat_shells') {
|
|
return shells?.call(fields) ?? Future.value({'chat_shells': []});
|
|
}
|
|
return output?.call(fields) ?? Future.value({'chat_shell_output': {}});
|
|
}
|
|
return super.call(type, fields);
|
|
}
|
|
|
|
void shell(String id, String status, {String session = 's'}) => emitEvent({
|
|
'session_id': session,
|
|
'kind': 'shell',
|
|
'shell': {'id': id, 'status': status, 'command': 'command $id'},
|
|
});
|
|
}
|
|
|
|
Map<String, dynamic> task(String id) => {
|
|
'id': id,
|
|
'status': 'running',
|
|
'command': 'command $id',
|
|
};
|