oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package equipo
2
3import (
4 "amadan.net/oficina/equipo/internal/wire"
5 "fmt"
6 "strings"
7 "testing"
8)
9
10func TestProposalFailureDetailAndPunctuation(t *testing.T) {
11 const want = "The branch was pushed, but the review request could not be created."
12 line := reasonLine("proposal_failed", "")
13 stopped := fmt.Sprintf(copyText("work.stopped"), line)
14 if line != want || stopped != "Stopped: "+want || strings.Count(line, ".") != 1 || strings.Count(stopped, ".") != 1 {
15 t.Fatalf("reason %q, stopped %q", line, stopped)
16 }
17 task := wire.Task{ID: "tk1", Stage: wire.StageInProgress, Steps: []wire.Step{{Specialist: wire.SpecialistEngineering, State: wire.StepDone, Pushed: true, Reason: "proposal_failed", CandidateSHA: strings.Repeat("a", 40)}}}
18 for _, it := range timelineOf(task, taskLineOf(task, "")) {
19 if it.Kind == "stopped" {
20 t.Fatal("successful push shown as stopped")
21 }
22 for _, text := range it.Text {
23 if text == want {
24 return
25 }
26 }
27 }
28 t.Fatal("successful step has no proposal diagnostic")
29}
30
31func TestCopyProposalFailureDetail(t *testing.T) {
32 for _, tc := range []struct {
33 pushed bool
34 reason string
35 }{{true, "proposal_failed"}, {false, "proposal_failed"}, {true, ""}} {
36 task := wire.Task{ID: "tkcopy", Stage: wire.StageInReview, Steps: []wire.Step{{Specialist: wire.SpecialistCopy, State: wire.StepDone, Pushed: tc.pushed, Reason: tc.reason, CandidateSHA: strings.Repeat("a", 40)}}}
37 items := timelineOf(task, taskLineOf(task, ""))
38 if !tc.pushed || tc.reason == "" {
39 if len(items) != 1 {
40 t.Fatalf("irrelevant Copy diagnostic: %+v", items)
41 }
42 continue
43 }
44 found := false
45 for _, it := range items {
46 if it.Kind == "stopped" {
47 t.Fatal("successful Copy push shown as stopped")
48 }
49 for _, text := range it.Text {
50 found = found || text == reasonLine("proposal_failed", "")
51 }
52 }
53 if !found {
54 t.Fatal("Copy step has no proposal diagnostic")
55 }
56 }
57}
58