package e2e import ( "net/http" "os/exec" "strings" "testing" ) // Chapter 24 lists the pages that do not exist, and the whole argument is that they never appear. func TestThePagesChapter24RefusesDoNotExist(t *testing.T) { if _, err := exec.LookPath("git"); err != nil { t.Skip("git is not installed") } in := newInstance(t) john := in.account("john") seed(t, in, john, "john", "johnbot") // The discovery pages are absent per rule 7, and the rest per chapter 1. absent := []string{ "/explore", "/trending", "/stars", "/followers", "/notifications", "/wiki", "/boards", "/insights", "/marketplace", "/gists", "/organizations", "/tour", "/edit", "/john/johnbot/wiki", "/john/johnbot/insights", "/john/johnbot/stars", "/john/johnbot/settings", "/john/johnbot/branches/protect", "/john/johnbot/merge-queue", } for _, path := range absent { code, _, _ := get(t, in.http.URL+path) if code != http.StatusNotFound { t.Errorf("%s answered %d, and chapter 24 says it does not exist", path, code) } } // And the one BUILD.md names as a trap, because every request for it is a request to be GitHub. code, _, page := get(t, in.http.URL+"/john/johnbot/threads") if code != http.StatusOK { t.Fatalf("the threads page answered %d", code) } for _, button := range []string{">merge<", "merge pull", "squash and merge", "rebase and merge"} { if strings.Contains(strings.ToLower(page), button) { t.Errorf("the thread list offers %q, and BUILD.md says the answer is a fetch command", button) } } }