import 'package:oto/oto/application.dart'; import 'package:oto/oto/commands/command.dart'; import 'package:oto/oto/data/command_data.dart'; import 'package:oto/oto/pipeline/pipeline.dart'; import 'package:test/test.dart'; void main() { setUp(() { Application.instance.property = {}; Application.instance.commandStates = {}; Application.instance.dataCommandMap = {}; }); test('parses minimal build yaml into DataBuild', () { const yaml = ''' property: workspace: . commands: - command: Print id: hello param: hi pipeline: id: main workflow: - exe: hello '''; final map = Application.getMapFromYamlA(yaml); expect(map, isNotNull); final build = DataBuild.fromJson(map!); expect(build.property!['workspace'], '.'); expect(build.commands, hasLength(1)); expect(build.commands.first.id, 'hello'); expect(build.commands.first.command, CommandType.Print); expect(build.pipeline!.id, 'main'); expect(build.pipeline!.workflow, hasLength(1)); }); test('tag system preserves single tag object values', () { Application.instance.property['items'] = [1, 2, 3]; Application.instance.property['config'] = {'a': 1}; final listValue = Command.replaceTagValue(''); expect(listValue, isA()); expect(listValue, equals([1, 2, 3])); final mapValue = Command.replaceTagValue(''); expect(mapValue, isA()); expect(mapValue, equals({'a': 1})); final embedded = Command.replaceTagValue('values='); expect(embedded, isA()); expect(embedded, contains('1')); }); test('pipeline validation rejects missing command id', () { final result = Pipeline.pipelineInitialize([ {'exe': 'doesNotExist'} ]); expect(result.enable, isFalse); expect(result.message, contains('doesNotExist')); }); }