import 'package:pipelines_app/core/api_gateway.dart'; /// Small, server-shaped fixtures shared by the graph domain tests. JsonMap step({ int sequence = 0, String stage = '', String status = 'completed', String outcome = '', String target = '', String startedAt = '', Map? control, }) { return { 'sequence': sequence, 'stage': stage, 'status': status, 'outcome': outcome, 'target': target, if (startedAt.isNotEmpty) 'started_at': startedAt, 'control': ?control, }; } JsonMap stage( String key, { Map edges = const {}, bool fallbackError = false, String type = 'model', }) { return { 'key': key, 'type': type, 'edges': edges, if (fallbackError) 'fallback_error': true, }; } /// plan -> build -> ship, with an implicit failure fallback on plan and an /// explicit terminal pair on ship. JsonMap linearGraph() => { 'stages': [ stage( 'plan', edges: {'success': 'build', 'error': '#'}, fallbackError: true, ), stage('build', edges: {'success': 'ship'}), stage( 'ship', edges: {'success': '#success', 'error': '#failure'}, ), ], }; /// a fans out to b/c and both converge on d. JsonMap diamondGraph() => { 'stages': [ stage( 'a', edges: {'success': 'b', 'approved': 'c', 'error': '#'}, fallbackError: true, ), stage('b', edges: {'success': 'd'}), stage('c', edges: {'success': 'd'}), stage('d', edges: {'success': '#success'}), ], }; /// a retries itself and can still succeed into b; terminal pair on b. JsonMap selfLoopGraph() => { 'stages': [ stage('a', edges: {'success': 'b', 'retry': 'a'}), stage( 'b', edges: {'success': '#success', 'error': '#failure'}, ), ], }; /// A definition with an absent edge, an empty target and an unknown target. JsonMap incompleteGraph() => { 'stages': [ stage( 'a', edges: { 'success': null, 'blocked': '', 'retry': 'ghost', 'error': '#', }, fallbackError: true, ), stage('b', edges: {'success': '#success'}), ], };