test(workflow): pin Ancestors on cycles and unknown needs, describe the cut-down fixture
- commit
- 1e8ab595185801f4fbf95ee8f49075975ab8dcdd
- author
- brice · · 2026-10-13 03:30 UTC
- committer
- brice · · 2026-10-18 14:59 UTC
- parent
- 8e90c04
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +15 -1
M workflow/job_eval_test.go +15 -1
| @@ -202,7 +202,9 @@ jobs: | |||
| 202 | 202 | } | |
| 203 | 203 | } | |
| 204 | 204 | ||
| 205 | - | // needsFailedDependency is the workflow of the recorded scenario of that name. | |
| 205 | + | // needsFailedDependency is a cut-down workflow of the recorded scenario of | |
| 206 | + | // that name (without with-failure, with-success and broken's outputs), plus a | |
| 207 | + | // made-up diamond job that GitHub did not run. | |
| 206 | 208 | const needsFailedDependency = `on: | |
| 207 | 209 | push: | |
| 208 | 210 | branches: ['scn/**'] | |
| @@ -254,3 +256,15 @@ func TestAncestors(t *testing.T) { | |||
| 254 | 256 | } | |
| 255 | 257 | } | |
| 256 | 258 | } | |
| 259 | + | ||
| 260 | + | // TestAncestorsCycleAndUnknownNeed covers what Parse rejects but a hand-built | |
| 261 | + | // Workflow may hold: a cycle ends, the start job and unknown ids are left out. | |
| 262 | + | func TestAncestorsCycleAndUnknownNeed(t *testing.T) { | |
| 263 | + | w := &Workflow{Jobs: []*Job{ | |
| 264 | + | {ID: "a", Needs: []string{"b", "ghost"}}, | |
| 265 | + | {ID: "b", Needs: []string{"a"}}, | |
| 266 | + | }} | |
| 267 | + | if got := w.Ancestors("a"); !reflect.DeepEqual(got, []string{"b"}) { | |
| 268 | + | t.Errorf("Ancestors(a) = %q, want [b]", got) | |
| 269 | + | } | |
| 270 | + | } | |
| @@ -202,7 +202,9 @@ jobs: | |||||
| 202 | } | 202 | } | ||
| 203 | } | 203 | } | ||
| 204 | 204 | ||||
| 205 | - | // needsFailedDependency is the workflow of the recorded scenario of that name. | 205 | + | // needsFailedDependency is a cut-down workflow of the recorded scenario of |
| 206 | + | // that name (without with-failure, with-success and broken's outputs), plus a | |||
| 207 | + | // made-up diamond job that GitHub did not run. | |||
| 206 | const needsFailedDependency = `on: | 208 | const needsFailedDependency = `on: | ||
| 207 | push: | 209 | push: | ||
| 208 | branches: ['scn/**'] | 210 | branches: ['scn/**'] | ||
| @@ -254,3 +256,15 @@ func TestAncestors(t *testing.T) { | |||||
| 254 | } | 256 | } | ||
| 255 | } | 257 | } | ||
| 256 | } | 258 | } | ||
| 259 | + | ||||
| 260 | + | // TestAncestorsCycleAndUnknownNeed covers what Parse rejects but a hand-built | |||
| 261 | + | // Workflow may hold: a cycle ends, the start job and unknown ids are left out. | |||
| 262 | + | func TestAncestorsCycleAndUnknownNeed(t *testing.T) { | |||
| 263 | + | w := &Workflow{Jobs: []*Job{ | |||
| 264 | + | {ID: "a", Needs: []string{"b", "ghost"}}, | |||
| 265 | + | {ID: "b", Needs: []string{"a"}}, | |||
| 266 | + | }} | |||
| 267 | + | if got := w.Ancestors("a"); !reflect.DeepEqual(got, []string{"b"}) { | |||
| 268 | + | t.Errorf("Ancestors(a) = %q, want [b]", got) | |||
| 269 | + | } | |||
| 270 | + | } | |||