package e2e import ( "net/http" "os/exec" "strings" "testing" ) // Chapter 12: barerepo records each push as a revision in the thread, or review reads the wrong code. func TestAProposalPushIsRecordedInItsThread(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git is not installed") } in := newInstance(t) john := in.account("john") mark := in.account("mark") seed(t, in, john, "john", "johnbot") work := clone(t, in, mark, "/john/johnbot") commit(t, work, "package main\n\nfunc main() {}\n", "a first attempt") run(t, work, "git", "push", "-q", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/new") // The second push is the one a reviewer needs to be told about. commit(t, work, "package main\n\nfunc main() { println(1) }\n", "a second attempt") out := run(t, work, "git", "push", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/1") if !strings.Contains(out, "updated") { t.Fatalf("the second push did not update the proposal:\n%s", out) } code, _, body := get(t, in.http.URL+"/john/johnbot/thread/1") if code != http.StatusOK { t.Fatalf("the thread answered %d", code) } if !strings.Contains(body, "pushed revision 2") { t.Errorf("the thread does not say the proposal moved:\n%s", body) } // The comment is mark's, because mark pushed it, and the page says who did everything else. i := strings.Index(body, "pushed revision 2") if !strings.Contains(body[max(0, i-400):i], "mark") { t.Error("the revision was recorded with nobody's name on it") } }