Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: go/src/infra/appengine/test-results/frontend/revision_test.go

Issue 2255433003: test-results: Add revisions handler (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Use c.BaseURL, not crRevURL always Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/appengine/test-results/frontend/revision.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package frontend
2
3 import (
4 "net/http"
5 "net/http/httptest"
6 "testing"
7
8 "github.com/luci/luci-go/server/router"
9 . "github.com/smartystreets/goconvey/convey"
10 )
11
12 func TestCommitPositionToHash(t *testing.T) {
13 t.Parallel()
14
15 data := map[string][]byte{
16 "1300": []byte(`{
17 "git_sha": "0dfc81bbe403cd98f4cd2d58e7817cdc8a881a5f",
18 "repo": "chromium/src",
19 "redirect_url": "https://chromium.googlesource.com/chromium/src/+/0dfc81bbe403cd 98f4cd2d58e7817cdc8a881a5f",
20 "project": "chromium",
21 "redirect_type": "GIT_FROM_NUMBER",
22 "repo_url": "https://chromium.googlesource.com/chromium/src/",
23 "kind": "crrev#redirectItem",
24 "etag": "\"kuKkspxlsT40mYsjSiqyueMe20E/qt8_sNqlQbK8xP9pkpc9EOsNyrE\""
25 }`),
26 }
27 handler := func(c *router.Context) {
28 b, ok := data[c.Params.ByName("pos")]
29 if !ok {
30 http.Error(c.Writer, "not found", http.StatusNotFound)
31 return
32 }
33 c.Writer.Write(b)
34 }
35 r := router.New()
36 r.GET("/:pos", router.MiddlewareChain{}, handler)
37
38 srv := httptest.NewServer(r)
39
40 client := crRevClient{
41 HTTPClient: &http.Client{},
42 BaseURL: srv.URL,
43 }
44
45 Convey("commitPositionToHash", t, func() {
46 Convey("existing position", func() {
47 hash, err := client.commitHash("1300")
48 So(err, ShouldBeNil)
49 So(hash, ShouldEqual, "0dfc81bbe403cd98f4cd2d58e7817cdc8 a881a5f")
50 })
51
52 Convey("non-existent position", func() {
53 _, err := client.commitHash("0")
54 So(err, ShouldNotBeNil)
55 })
56 })
57 }
OLDNEW
« no previous file with comments | « go/src/infra/appengine/test-results/frontend/revision.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698