func TestSummarizeIssue(t *testing.T) { f, err := os.Open("testdata/issue-9910043-msgs.json") if err != nil { t.Fatal(err) } defer f.Close() env := qophertest.NewEnv(t) rt := qophertest.NewFakeRoundTripper(t) rt.AddURL("https://codereview.appspot.com/api/9910043?messages=true", &http.Response{ Status: "200 OK", StatusCode: 200, Body: f, }) env.SetHTTPClient(&http.Client{Transport: rt}) im := summarizeIssue(env, 9910043) if im.err != nil { t.Fatalf("Error summarizing: %v", im.err) } want := issueMeta{ issue: 9910043, lastModified: "2013-06-03 19:50:42.516010", policyVersion: policyVersion, reviewer: "dvyukov", } if im != want { t.Errorf("summary = %+v; want %+v", im, want) } }
func TestSummarizeIssue_Submitted(t *testing.T) { f, err := os.Open("testdata/issue-5992058-msgs.json") if err != nil { t.Fatal(err) } defer f.Close() env := qophertest.NewEnv(t) rt := qophertest.NewFakeRoundTripper(t) rt.AddURL("https://codereview.appspot.com/api/5992058?messages=true", &http.Response{ Status: "200 OK", StatusCode: 200, Body: f, }) env.SetHTTPClient(&http.Client{Transport: rt}) im := summarizeIssue(env, 5992058) if im.err != nil { t.Fatalf("Error summarizing: %v", im.err) } want := issueMeta{ issue: 5992058, lastModified: "2012-04-06 21:18:41.128683", policyVersion: policyVersion, reviewer: "close", } if im != want { t.Errorf("summary = %+v; want %+v", im, want) } }
func TestLive(t *testing.T) { if !*live { t.Skipf("skipping") } var task codereviewTask tasks, err := task.Poll(qophertest.NewEnv(t)) if err != nil { t.Fatal(err) } t.Logf("Got %d tasks", len(tasks)) for _, task := range tasks { t.Logf("Task: %+v", task) } }