File view with blame information shown in the left gutter beside each line.

barerepo / server / e2e/revision_test.go
43 lines · 1.5kb · master
log files threads runs releases config jump to file t
133728e barerepo 1mo
1
package e2e
133728e barerepo 1mo
2
133728e barerepo 1mo
3
import (
133728e barerepo 1mo
4
"net/http"
133728e barerepo 1mo
5
"os/exec"
133728e barerepo 1mo
6
"strings"
133728e barerepo 1mo
7
"testing"
133728e barerepo 1mo
8
)
133728e barerepo 1mo
9
133728e barerepo 1mo
10
// Chapter 12: barerepo records each push as a revision in the thread, or review reads the wrong code.
133728e barerepo 1mo
11
func TestAProposalPushIsRecordedInItsThread(t *testing.T) {
133728e barerepo 1mo
12
if _, err := exec.LookPath("git"); err != nil {
133728e barerepo 1mo
13
t.Skip("git is not installed")
133728e barerepo 1mo
14
}
133728e barerepo 1mo
15
in := newInstance(t)
133728e barerepo 1mo
16
john := in.account("john")
133728e barerepo 1mo
17
mark := in.account("mark")
133728e barerepo 1mo
18
seed(t, in, john, "john", "johnbot")
133728e barerepo 1mo
19
133728e barerepo 1mo
20
work := clone(t, in, mark, "/john/johnbot")
133728e barerepo 1mo
21
commit(t, work, "package main\n\nfunc main() {}\n", "a first attempt")
133728e barerepo 1mo
22
run(t, work, "git", "push", "-q", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/new")
133728e barerepo 1mo
23
133728e barerepo 1mo
24
// The second push is the one a reviewer needs to be told about.
133728e barerepo 1mo
25
commit(t, work, "package main\n\nfunc main() { println(1) }\n", "a second attempt")
133728e barerepo 1mo
26
out := run(t, work, "git", "push", in.url(mark, "/john/johnbot"), "HEAD:refs/proposals/1")
133728e barerepo 1mo
27
if !strings.Contains(out, "updated") {
133728e barerepo 1mo
28
t.Fatalf("the second push did not update the proposal:\n%s", out)
133728e barerepo 1mo
29
}
133728e barerepo 1mo
30
133728e barerepo 1mo
31
code, _, body := get(t, in.http.URL+"/john/johnbot/thread/1")
133728e barerepo 1mo
32
if code != http.StatusOK {
133728e barerepo 1mo
33
t.Fatalf("the thread answered %d", code)
133728e barerepo 1mo
34
}
133728e barerepo 1mo
35
if !strings.Contains(body, "pushed revision 2") {
133728e barerepo 1mo
36
t.Errorf("the thread does not say the proposal moved:\n%s", body)
133728e barerepo 1mo
37
}
133728e barerepo 1mo
38
// The comment is mark's, because mark pushed it, and the page says who did everything else.
133728e barerepo 1mo
39
i := strings.Index(body, "pushed revision 2")
133728e barerepo 1mo
40
if !strings.Contains(body[max(0, i-400):i], "mark") {
133728e barerepo 1mo
41
t.Error("the revision was recorded with nobody's name on it")
133728e barerepo 1mo
42
}
133728e barerepo 1mo
43
}
history · rawbarerepo 0.1.0