|
| 1 | +// SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +package executor |
| 4 | + |
| 5 | +import ( |
| 6 | + "testing" |
| 7 | + |
| 8 | + "github.com/mendixlabs/mxcli/sdk/microflows" |
| 9 | +) |
| 10 | + |
| 11 | +// TestHasExplicitFalseBranchAnchor pins ako's review follow-up for PR #364: |
| 12 | +// the heuristic that decides whether a false-branch flow carries an explicit |
| 13 | +// anchor annotation should fire only on the AnchorTop→AnchorBottom pair and |
| 14 | +// must stay dormant for nil flows, builder defaults, and any other side |
| 15 | +// combination. |
| 16 | +func TestHasExplicitFalseBranchAnchor(t *testing.T) { |
| 17 | + tests := []struct { |
| 18 | + name string |
| 19 | + flow *microflows.SequenceFlow |
| 20 | + want bool |
| 21 | + }{ |
| 22 | + {name: "nil flow", flow: nil, want: false}, |
| 23 | + { |
| 24 | + name: "builder default right→left", |
| 25 | + flow: µflows.SequenceFlow{OriginConnectionIndex: AnchorRight, DestinationConnectionIndex: AnchorLeft}, |
| 26 | + want: false, |
| 27 | + }, |
| 28 | + { |
| 29 | + name: "split default bottom→top", |
| 30 | + flow: µflows.SequenceFlow{OriginConnectionIndex: AnchorBottom, DestinationConnectionIndex: AnchorTop}, |
| 31 | + want: false, |
| 32 | + }, |
| 33 | + { |
| 34 | + name: "authored top→bottom", |
| 35 | + flow: µflows.SequenceFlow{OriginConnectionIndex: AnchorTop, DestinationConnectionIndex: AnchorBottom}, |
| 36 | + want: true, |
| 37 | + }, |
| 38 | + { |
| 39 | + name: "only origin customised", |
| 40 | + flow: µflows.SequenceFlow{OriginConnectionIndex: AnchorTop, DestinationConnectionIndex: AnchorTop}, |
| 41 | + want: false, |
| 42 | + }, |
| 43 | + { |
| 44 | + name: "only destination customised", |
| 45 | + flow: µflows.SequenceFlow{OriginConnectionIndex: AnchorBottom, DestinationConnectionIndex: AnchorBottom}, |
| 46 | + want: false, |
| 47 | + }, |
| 48 | + } |
| 49 | + |
| 50 | + for _, tc := range tests { |
| 51 | + t.Run(tc.name, func(t *testing.T) { |
| 52 | + got := hasExplicitFalseBranchAnchor(tc.flow) |
| 53 | + if got != tc.want { |
| 54 | + t.Fatalf("hasExplicitFalseBranchAnchor(%s) = %v, want %v", tc.name, got, tc.want) |
| 55 | + } |
| 56 | + }) |
| 57 | + } |
| 58 | +} |
0 commit comments