import 'dart:io';
import 'package:oto/cli/commands/scheduler/scheduler_manager.dart';

void main() async {
  final file = File('test_pipeline.yaml');
  await file.writeAsString('''
scheduler:
  alias: test_alias
commands: []
pipeline:
  id: main
  workflow: []
''');

  final manager = SchedulerManager.create();
  final systemdDir = Directory('/config/.config/systemd/user');
  if (!systemdDir.existsSync()) {
    systemdDir.createSync(recursive: true);
  }
  try {
    await manager.regist('test_pipeline.yaml');
    print('Success!');
  } catch (e, stack) {
    print('Failed with: $e');
    print(stack);
  } finally {
    if (file.existsSync()) file.deleteSync();
    final copied = File('scheduler/test_alias.yaml');
    if (copied.existsSync()) copied.deleteSync();
  }
}
