gunk-dev/the-valley

read_test.go

sourced03575e2a892main's published tip history
21.7 KiB
1package main
2
3import (
4 "bytes"
5 "context"
6 "encoding/json"
7 "errors"
8 "fmt"
9 "os"
10 "path/filepath"
11 "reflect"
12 "strconv"
13 "strings"
14 "testing"
15
16 "the-valley/webui/export"
17)
18
19// fails runs one pass through run, the program's entry point, and fails the
20// test unless the pass exits 1 having sent and written nothing: to rv when
21// it is given, and otherwise to a fresh --out directory. It returns what
22// the pass said on stderr.
23func (v *testValley) fails(rv *testReceiver, more ...string) string {
24 v.t.Helper()
25 out := filepath.Join(v.t.TempDir(), "export")
26 to := []string{"--out", out}
27 if rv != nil {
28 rv.taken()
29 to = []string{"--receiver", rv.server.URL}
30 }
31 var stdout, stderr bytes.Buffer
32 if code := run(context.Background(), v.args(append(to, more...)...), &stdout, &stderr); code != 1 {
33 v.t.Fatalf("the pass exited %d, want 1\nstdout:\n%s\nstderr:\n%s", code, stdout.String(), stderr.String())
34 }
35 if rv != nil {
36 sameRequests(v.t, "a failed pass", rv.taken())
37 } else if _, err := os.Stat(out); !errors.Is(err, os.ErrNotExist) {
38 v.t.Errorf("a failed pass wrote %s", out)
39 }
40 return stderr.String()
41}
42
43func mustSay(t *testing.T, what, said, want string) {
44 t.Helper()
45 if !strings.Contains(said, want) {
46 t.Errorf("%s: the pass did not say %q:\n%s", what, want, said)
47 }
48}
49
50// elsewhere makes a second instance beside the first, with projects of the
51// same names: valley, which allows app and site; app, which declares
52// itself public and carries a sentinel of its own; and site, with no main.
53// It returns the instance repository.
54func (v *testValley) elsewhere(sentinel string) string {
55 v.t.Helper()
56 srv := filepath.Join(v.root, "elsewhere")
57 for _, name := range []string{"valley", "app", "site"} {
58 v.run("", "git", "init", "--quiet", "--bare", filepath.Join(srv, name+".git"))
59 }
60 for _, name := range []string{"valley", "app"} {
61 work := filepath.Join(v.root, "elsewhere-work", name)
62 v.run("", "git", "init", "--quiet", work)
63 v.run(work, "git", "remote", "add", "origin", filepath.Join(srv, name+".git"))
64 v.work["elsewhere/"+name] = work
65 }
66 v.write(filepath.Join(v.work["elsewhere/valley"], "policy", "instance", "floor.cue"), "package verification\n")
67 v.declare("elsewhere/valley", `instance: projects: {
68 app: visibility: "public"
69 site: visibility: "public"
70}`)
71 v.write(filepath.Join(v.work["elsewhere/app"], "policy", "valley"), filepath.Join(srv, "valley.git")+"\n")
72 v.write(filepath.Join(v.work["elsewhere/app"], "source.txt"), sentinel+"\n")
73 v.declare("elsewhere/app", `project: visibility: "public"`)
74 list := v.runInput("", "app\nsite\nvalley\n", "git", "-C", filepath.Join(srv, "valley.git"), "hash-object", "-w", "--stdin")
75 v.run("", "git", "-C", filepath.Join(srv, "valley.git"), "update-ref", projectsRef, strings.TrimSpace(list))
76 return filepath.Join(srv, "valley.git")
77}
78
79// Two instances publish a project called app. When the instance repository
80// the publisher is given points at the other with policy/valley, the CLI
81// would read the other's app, and the pass refuses before it reads any
82// project.
83func TestAnotherInstanceIsNeverRead(t *testing.T) {
84 v := newValley(t)
85 other := v.elsewhere("elsewhere-app-source-c3d1")
86 v.write(filepath.Join(v.work["valley"], "policy", "valley"), other+"\n")
87 v.commit("valley", "valley: point at another instance")
88
89 mustSay(t, "--out", v.fails(nil), "holds policy/valley on main")
90 rv := newReceiver(t, v)
91 mustSay(t, "--receiver", v.fails(rv), "holds policy/valley on main")
92 if _, err := os.Stat(filepath.Join(v.root, "cache", "valley-web-publish", "repos", "app.git")); !errors.Is(err, os.ErrNotExist) {
93 t.Errorf("the pass fetched a project before it refused the instance repository")
94 }
95
96 // The CLI reads policy/valley up to a # and without the spaces around
97 // it, so an instance repository whose URL holds them is refused before
98 // the pass runs: policy/valley would name another.
99 instance := filepath.Join(v.srv, "valley.git")
100 for _, url := range []string{instance + "#other", " " + instance, instance + "\n" + other} {
101 var stdout, stderr bytes.Buffer
102 if code := run(context.Background(), v.args("--out", t.TempDir(), "--instance-repo", url), &stdout, &stderr); code != 2 {
103 t.Errorf("--instance-repo %q: the pass exited %d, want 2", url, code)
104 }
105 }
106}
107
108// The pass reads the instance repository at the main it began with, and
109// the CLI never reads that main again. So a policy/valley that lands on
110// main while the CLI reads changes nothing in the read: not when main is
111// put back before the read ends, which no comparison of main before and
112// after the read could see, and not when it stays, which the next pass
113// refuses. Read through the pointer, the export would hold the other
114// instance's app.
115func TestAPointerLandingDuringAReadIsNeverRead(t *testing.T) {
116 const otherSource = "elsewhere-app-source-c3d1"
117 for _, restored := range []bool{true, false} {
118 t.Run(fmt.Sprintf("restored %v", restored), func(t *testing.T) {
119 v := newValley(t)
120 other := v.elsewhere(otherSource)
121 instance := filepath.Join(v.srv, "valley.git")
122 began := strings.TrimSpace(v.run("", "git", "-C", instance, "rev-parse", "main"))
123 work := v.work["valley"]
124 v.run(work, "git", "checkout", "--quiet", "-b", "pointer")
125 v.write(filepath.Join(work, "policy", "valley"), other+"\n")
126 v.run(work, "git", "add", "--all")
127 v.run(work, "git", "commit", "--quiet", "-m", "valley: point at another instance")
128 pointer := strings.TrimSpace(v.run(work, "git", "rev-parse", "HEAD"))
129 v.run(work, "git", "push", "--quiet", "origin", "pointer")
130
131 // The CLI's first command moves main to the pointer before it
132 // runs. When restored, main is put back once the second, the
133 // pending listing, is done: the CLI has then read the pointer
134 // twice, if it reads main at all, and main is where the pass
135 // began.
136 wrapper := filepath.Join(v.root, "bin", "valley")
137 data, err := os.ReadFile(wrapper)
138 if err != nil {
139 t.Fatal(err)
140 }
141 shebang, rest, _ := strings.Cut(string(data), "\n")
142 rest = strings.Replace(rest, "exec ", "", 1)
143 count := filepath.Join(v.root, "count")
144 restore := ":"
145 if restored {
146 restore = fmt.Sprintf("git -C %s update-ref refs/heads/main %s", instance, began)
147 }
148 v.write(wrapper, fmt.Sprintf(`%s
149n=$(( $(cat %[2]s 2>/dev/null || echo 0) + 1 )); echo "$n" > %[2]s
150if [ "$n" = 1 ]; then git -C %[3]s update-ref refs/heads/main %[4]s; fi
151rc=0
152%[5]s || rc=$?
153if [ "$n" = 2 ]; then %[6]s; fi
154exit "$rc"
155`, shebang, count, instance, pointer, strings.TrimSpace(rest), restore))
156
157 dir, _, e := v.out()
158 if calls, _ := strconv.Atoi(strings.TrimSpace(v.run("", "cat", count))); calls < 2 {
159 t.Fatalf("the CLI ran %d commands, so the pointer was never in place while it read", calls)
160 }
161 if got := names(e); !reflect.DeepEqual(got, []string{"app"}) {
162 t.Fatalf("the export holds %v, want app alone", got)
163 }
164 app := strings.TrimSpace(v.run("", "git", "-C", filepath.Join(v.srv, "app.git"), "rev-parse", "main"))
165 if e.Projects[0].SourceTip != app {
166 t.Errorf("the export's app is at %s, and this instance's app is at %s", e.Projects[0].SourceTip, app)
167 }
168 if strings.Contains(v.unbundled(filepath.Join(dir, "bundles", "app.bundle")), otherSource) {
169 t.Errorf("the bundle of app holds the other instance's source")
170 }
171 if len(knotOf(t, e.Projects[0], v.knots["bug"]).Comments) != 1 {
172 t.Errorf("the export's app does not hold this instance's plan")
173 }
174
175 if restored {
176 return
177 }
178 v.write(wrapper, shebang+"\n"+rest)
179 mustSay(t, "the next pass", v.fails(nil), "holds policy/valley on main")
180 })
181 }
182}
183
184// A project the instance allows that cannot be read fails the pass, which
185// sends and writes nothing: published without it, the export would take
186// it off the web. A project with no main yet is private, and the pass
187// goes on.
188func TestAProjectThatCannotBeReadFailsThePass(t *testing.T) {
189 cases := []struct {
190 name string
191 upload bool
192 breaks func(v *testValley) []string
193 says string
194 }{
195 {
196 name: "the pending listing cannot read site",
197 upload: true,
198 breaks: func(v *testValley) []string {
199 if err := os.Rename(filepath.Join(v.srv, "site.git"), filepath.Join(v.srv, "site.moved")); err != nil {
200 v.t.Fatal(err)
201 }
202 return nil
203 },
204 says: "site: the pending listing could not read it",
205 },
206 {
207 name: "site's main cannot be fetched into its mirror",
208 breaks: func(v *testValley) []string {
209 mirror := filepath.Join(v.root, "cache", "valley-web-publish", "repos", "site.git")
210 v.run("", "git", "init", "--quiet", "--bare", mirror)
211 v.run("", "git", "-C", mirror, "config", "core.repositoryformatversion", "99")
212 return nil
213 },
214 says: "site: could not read main",
215 },
216 {
217 name: "discovery fails, and the CLI lists its own repository alone",
218 breaks: func(v *testValley) []string {
219 list := v.runInput("", "app\nsite\nvalley\nnot a name\n", "git", "-C", filepath.Join(v.srv, "valley.git"), "hash-object", "-w", "--stdin")
220 v.run("", "git", "-C", filepath.Join(v.srv, "valley.git"), "update-ref", projectsRef, strings.TrimSpace(list))
221 return nil
222 },
223 says: "valley plan --all lists _pointer, and the instance repository publishes app, not a name, site, valley",
224 },
225 {
226 name: "the instance publishes no project list",
227 breaks: func(v *testValley) []string {
228 v.run("", "git", "-C", filepath.Join(v.srv, "valley.git"), "update-ref", "-d", projectsRef)
229 return nil
230 },
231 says: "could not read main and refs/the-valley/projects in the instance repository",
232 },
233 {
234 name: "the schema cannot be read",
235 breaks: func(v *testValley) []string { return []string{"--schema", filepath.Join(v.root, "no-such.cue")} },
236 says: "does not load",
237 },
238 }
239 for _, c := range cases {
240 t.Run(c.name, func(t *testing.T) {
241 v := newValley(t)
242 more := c.breaks(v)
243 var rv *testReceiver
244 if c.upload {
245 rv = newReceiver(t, v)
246 }
247 mustSay(t, c.name, v.fails(rv, more...), c.says)
248 })
249 }
250
251 t.Run("a project with no main is private", func(t *testing.T) {
252 v := newValley(t)
253 v.run("", "git", "init", "--quiet", "--bare", filepath.Join(v.srv, "fresh.git"))
254 list := v.runInput("", "app\nfresh\nsite\nvalley\n", "git", "-C", filepath.Join(v.srv, "valley.git"), "hash-object", "-w", "--stdin")
255 v.run("", "git", "-C", filepath.Join(v.srv, "valley.git"), "update-ref", projectsRef, strings.TrimSpace(list))
256 v.declare("valley", `instance: projects: {
257 app: visibility: "public"
258 fresh: visibility: "public"
259 site: visibility: "public"
260}`)
261 stdout, _ := v.publish("--out", filepath.Join(t.TempDir(), "export"))
262 mustSay(t, "a project with no main", stdout, "public: app; private: fresh, site, valley")
263 })
264}
265
266// The bundles of an export are held to --max-bundles together, and the
267// state and the cache to --max-storage, before anything is sent. What a
268// program prints is held to a bound: git's output past it fails the call,
269// and a declaration whose export is past cue's bound is invalid.
270func TestBoundsStopThePass(t *testing.T) {
271 v := newValley(t)
272 rv := newReceiver(t, v)
273 mustSay(t, "--max-bundles", v.fails(rv, "--max-bundles", "100"), "more than --max-bundles 100")
274 mustSay(t, "--max-storage", v.fails(nil, "--max-storage", "1K"), "more than --max-storage 1024")
275 for _, size := range []string{"0", "-1", "1X", "K", "9000000000T"} {
276 var stdout, stderr bytes.Buffer
277 if code := run(context.Background(), v.args("--out", t.TempDir(), "--max-bundles", size), &stdout, &stderr); code != 2 {
278 t.Errorf("--max-bundles %s: the pass exited %d, want 2", size, code)
279 }
280 }
281
282 big := v.runInput("", strings.Repeat("x", maxGitOutput+1), "git", "-C", filepath.Join(v.srv, "app.git"), "hash-object", "-w", "--stdin")
283 if _, err := git(context.Background(), filepath.Join(v.srv, "app.git"), "cat-file", "blob", strings.TrimSpace(big)); !errors.Is(err, errTooLong) {
284 t.Errorf("git printing more than %d bytes returned %v, want errTooLong", maxGitOutput, err)
285 }
286
287 v.declare("valley", `import "list"
288
289instance: projects: {for i in list.Range(0, 9000, 1) {"project-with-a-long-name-for-the-bound-on-cue-output-\(i)": visibility: "public"}}`)
290 stdout, stderr := v.publish("--out", filepath.Join(t.TempDir(), "export"))
291 mustSay(t, "a declaration past cue's bound", stdout, "public: none")
292 mustSay(t, "a declaration past cue's bound", stderr, "cue exported more than")
293}
294
295// objects is every object a repository holds, decompressed, as git
296// cat-file --batch-all-objects prints them.
297func (v *testValley) objects(repo string) string {
298 v.t.Helper()
299 return v.run("", "git", "-C", repo, "cat-file", "--batch-all-objects", "--batch")
300}
301
302// unbundled is every object a bundle carries, decompressed.
303func (v *testValley) unbundled(bundle string) string {
304 v.t.Helper()
305 repo := filepath.Join(v.t.TempDir(), "unbundled.git")
306 v.run("", "git", "init", "--quiet", "--bare", repo)
307 v.run("", "git", "-C", repo, "bundle", "unbundle", bundle)
308 return v.objects(repo)
309}
310
311// noSentinels fails the test if any private sentinel appears in what.
312func noSentinels(t *testing.T, where, what string) {
313 t.Helper()
314 for _, s := range []string{sentinelSource, sentinelBody, sentinelComment} {
315 if strings.Contains(what, s) {
316 t.Errorf("%s holds the private sentinel %s", where, s)
317 }
318 }
319}
320
321// inActive runs f over the generation the receiver serves.
322func (rv *testReceiver) inActive(f func(export.Generation)) {
323 rv.t.Helper()
324 rv.mu.Lock()
325 defer rv.mu.Unlock()
326 g, release, err := rv.store.Open()
327 defer release()
328 if err != nil {
329 rv.t.Fatal(err)
330 }
331 f(g)
332}
333
334// No private sentinel leaves the host: not in export.json, and not in any
335// object of any bundle, whether the export is written to --out or
336// uploaded and activated by a receiver.
337func TestPrivateSentinelsNeverLeave(t *testing.T) {
338 v := newValley(t)
339 held := v.objects(filepath.Join(v.srv, "site.git"))
340 for _, s := range []string{sentinelSource, sentinelBody, sentinelComment} {
341 if !strings.Contains(held, s) {
342 t.Fatalf("site's repository does not hold the sentinel %s, so the test proves nothing", s)
343 }
344 }
345
346 dir, _, _ := v.out()
347 data, err := os.ReadFile(filepath.Join(dir, export.ExportFile))
348 if err != nil {
349 t.Fatal(err)
350 }
351 noSentinels(t, "--out's export.json", string(data))
352 bundles, _ := filepath.Glob(filepath.Join(dir, "bundles", "*"))
353 if len(bundles) != 1 {
354 t.Fatalf("--out holds the bundles %v, want app's alone", bundles)
355 }
356 noSentinels(t, "--out's bundle of app", v.unbundled(bundles[0]))
357
358 rv := newReceiver(t, v)
359 v.publish("--receiver", rv.server.URL)
360 rv.inActive(func(g export.Generation) {
361 data, err := os.ReadFile(g.ExportPath())
362 if err != nil {
363 t.Fatal(err)
364 }
365 noSentinels(t, "the receiver's export.json", string(data))
366 repos, _ := filepath.Glob(filepath.Join(g.Dir, "repos", "*"))
367 if len(repos) != 1 {
368 t.Fatalf("the receiver serves the repositories %v, want app's alone", repos)
369 }
370 noSentinels(t, "the receiver's repository of app", v.objects(repos[0]))
371 })
372}
373
374// A project that declares itself private again is gone from the next
375// export the receiver activates: from export.json and from its
376// repositories.
377func TestAProjectMadePrivateLeavesTheReceiver(t *testing.T) {
378 v := newValley(t)
379 rv := newReceiver(t, v)
380 v.declare("site", `project: visibility: "public"`)
381 v.publish("--receiver", rv.server.URL)
382 if got := names(rv.active()); !reflect.DeepEqual(got, []string{"app", "site"}) {
383 t.Fatalf("the receiver serves %v, want app and site", got)
384 }
385
386 v.declare("site", `project: visibility: "private"`)
387 stdout, _ := v.publish("--receiver", rv.server.URL)
388 mustSay(t, "site made private", stdout, "public: app; private: site, valley")
389 if got := names(rv.active()); !reflect.DeepEqual(got, []string{"app"}) {
390 t.Errorf("the receiver serves %v once site is private, want app alone", got)
391 }
392 rv.inActive(func(g export.Generation) {
393 repo, _ := g.Repo("site")
394 if _, err := os.Stat(repo); !errors.Is(err, os.ErrNotExist) {
395 t.Errorf("the receiver's active generation still holds site's repository")
396 }
397 data, err := os.ReadFile(g.ExportPath())
398 if err != nil {
399 t.Fatal(err)
400 }
401 noSentinels(t, "the receiver's export.json once site is private", string(data))
402 })
403}
404
405// landedChangeID is a change of app's that the integrator lands as a new
406// commit, so only its transfer statement shows it landed.
407const landedChangeID = "kpqrstuvwxyzkpqrstuvwxyzkpqrstuv"
408
409// publishSigners publishes, in the instance repository, the signers a
410// client verifies the integrator's landings with, as the host's signers
411// publisher writes them: a tree at refs/the-valley/signers holding the
412// known-signers file and the integrator's name. The integrator's key is
413// made here; its verifier line is the file's one line.
414func (v *testValley) publishSigners(name string) (key string) {
415 v.t.Helper()
416 key = filepath.Join(v.root, "integrator.key")
417 v.run("", "ssh-keygen", "-q", "-t", "ed25519", "-N", "", "-C", "integrator", "-f", key)
418 instance := filepath.Join(v.srv, "valley.git")
419 keys := v.runInput("", v.run("", "attest", "key", "--key", key, "--name", name), "git", "-C", instance, "hash-object", "-w", "--stdin")
420 named := v.runInput("", name, "git", "-C", instance, "hash-object", "-w", "--stdin")
421 tree := v.runInput("", fmt.Sprintf("100644 blob %s\tintegrator-name\n100644 blob %s\tknown-signers\n",
422 strings.TrimSpace(named), strings.TrimSpace(keys)), "git", "-C", instance, "mktree")
423 v.run("", "git", "-C", instance, "update-ref", "refs/the-valley/signers", strings.TrimSpace(tree))
424 return key
425}
426
427// landByIntegration readies a change on app and lands it as the
428// integrator does: a new commit on main, the outcome record, and the
429// transfer statement, signed with key under name.
430func (v *testValley) landByIntegration(key, name string) {
431 v.t.Helper()
432 work, bare := v.work["app"], filepath.Join(v.srv, "app.git")
433 v.run(work, "git", "checkout", "--quiet", "-b", "landed", "main")
434 v.write(filepath.Join(work, "landed.txt"), "landed\n")
435 v.run(work, "git", "add", "landed.txt")
436 v.run(work, "git", "commit", "--quiet", "-m", "app: a change the integrator lands")
437 head := strings.TrimSpace(v.run(work, "git", "rev-parse", "HEAD"))
438 v.run(work, "git", "push", "--quiet", "origin", "landed")
439 v.valley("app", "ready", "--change", landedChangeID, "landed")
440 // main moves on first, so the landing is a new commit and never the
441 // change's head.
442 v.run(work, "git", "checkout", "--quiet", "main")
443 v.write(filepath.Join(work, "moved.txt"), "moved\n")
444 v.commit("app", "app: main moves on")
445 tip := strings.TrimSpace(v.run(work, "git", "rev-parse", "main"))
446 v.run(work, "git", "checkout", "--quiet", "-b", "landing", "main")
447 v.run(work, "git", "cherry-pick", head)
448 landed := strings.TrimSpace(v.run(work, "git", "rev-parse", "HEAD"))
449 v.run(work, "git", "push", "--quiet", "origin", "landing:main")
450 v.run(work, "git", "checkout", "--quiet", "main")
451 v.run(work, "git", "pull", "--quiet", "--ff-only", "origin", "main")
452
453 request := "c-" + landedChangeID
454 memo := v.runInput("", fmt.Sprintf("%s %s 0123456789abcdef land\n", head, tip), "git", "-C", bare, "hash-object", "-w", "--stdin")
455 v.run("", "git", "-C", bare, "update-ref", "refs/the-valley/integration-outcomes/main/"+request, strings.TrimSpace(memo))
456 digest := func(rev string) string {
457 out := strings.TrimSpace(v.run("", "attest", "digest", "--repo", work, "--rev", rev))
458 _, d, _ := strings.Cut(out, ":")
459 return d
460 }
461 statement, err := json.Marshal(map[string]any{
462 "statementType": "the-valley/attestation/v1",
463 "subject": map[string]any{"primary": "valley-tree-v1",
464 "digest": map[string]string{"valley-tree-v1": digest(landed), "git-sha1": landed}},
465 "predicateType": "the-valley/integration/transfer/v1",
466 "predicate": map[string]any{"change": request, "target": "refs/heads/main",
467 "base": map[string]string{"valley-tree-v1": digest(head)},
468 "policy": map[string]string{"sha256": strings.Repeat("ab", 32), "git-sha1": tip}, "required": "none"},
469 })
470 if err != nil {
471 v.t.Fatal(err)
472 }
473 path := filepath.Join(v.root, "statement.json")
474 v.write(path, string(statement))
475 note := v.runInput("", v.run("", "attest", "render", path), "attest", "sign", "--key", key, "--name", name)
476 blob := v.runInput("", note, "git", "-C", bare, "hash-object", "-w", "--stdin")
477 tree := v.runInput("", "100644 blob "+strings.TrimSpace(blob)+"\ttransfer.note\n", "git", "-C", bare, "mktree")
478 v.run("", "git", "-C", bare, "update-ref",
479 fmt.Sprintf("refs/the-valley/attestations/%s/%08x", digest(landed), len(name)), strings.TrimSpace(tree))
480}
481
482// The CLI the publisher runs verifies a landing with the signers the
483// instance repository publishes, and with nothing the caller's environment
484// names: a landed change is not exported as ready for approval. Without
485// the publication the landing is not believed, and the change is.
486func TestLandingsAreVerifiedWithThePublishedSigners(t *testing.T) {
487 v := newValley(t)
488 needTool(t, "attest")
489 needTool(t, "ssh-keygen")
490 const signer = "valley-host/integration"
491 key := v.publishSigners(signer)
492 v.landByIntegration(key, signer)
493
494 // The caller's own material names the signer with another key, under
495 // which the statement would not verify.
496 other := filepath.Join(v.root, "other.key")
497 v.run("", "ssh-keygen", "-q", "-t", "ed25519", "-N", "", "-C", "other", "-f", other)
498 otherSigners := filepath.Join(v.root, "other-signers")
499 v.write(otherSigners, v.run("", "attest", "key", "--key", other, "--name", signer))
500 t.Setenv("VALLEY_KNOWN_SIGNERS", otherSigners)
501 t.Setenv("VALLEY_INTEGRATOR_SIGNER", signer)
502
503 changes := func() []string {
504 _, _, e := v.out()
505 ids := []string{}
506 for _, c := range e.Projects[0].Changes {
507 ids = append(ids, c.ChangeID)
508 }
509 return ids
510 }
511 if got := changes(); !reflect.DeepEqual(got, []string{changeID}) {
512 t.Errorf("with the published signers, app's changes ready for approval are %v, want %s alone", got, changeID)
513 }
514 v.run("", "git", "-C", filepath.Join(v.srv, "valley.git"), "update-ref", "-d", "refs/the-valley/signers")
515 got := changes()
516 if len(got) != 2 || !strings.Contains(strings.Join(got, " "), landedChangeID) {
517 t.Errorf("with no published signers, app's changes ready for approval are %v, want the landed change among them", got)
518 }
519}