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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/appengine/test-results/frontend/revision_test.go
diff --git a/go/src/infra/appengine/test-results/frontend/revision_test.go b/go/src/infra/appengine/test-results/frontend/revision_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..a967624eecda254eee89356ae1b066396c843224
--- /dev/null
+++ b/go/src/infra/appengine/test-results/frontend/revision_test.go
@@ -0,0 +1,57 @@
+package frontend
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "github.com/luci/luci-go/server/router"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestCommitPositionToHash(t *testing.T) {
+ t.Parallel()
+
+ data := map[string][]byte{
+ "1300": []byte(`{
+ "git_sha": "0dfc81bbe403cd98f4cd2d58e7817cdc8a881a5f",
+"repo": "chromium/src",
+"redirect_url": "https://chromium.googlesource.com/chromium/src/+/0dfc81bbe403cd98f4cd2d58e7817cdc8a881a5f",
+"project": "chromium",
+"redirect_type": "GIT_FROM_NUMBER",
+"repo_url": "https://chromium.googlesource.com/chromium/src/",
+"kind": "crrev#redirectItem",
+"etag": "\"kuKkspxlsT40mYsjSiqyueMe20E/qt8_sNqlQbK8xP9pkpc9EOsNyrE\""
+}`),
+ }
+ handler := func(c *router.Context) {
+ b, ok := data[c.Params.ByName("pos")]
+ if !ok {
+ http.Error(c.Writer, "not found", http.StatusNotFound)
+ return
+ }
+ c.Writer.Write(b)
+ }
+ r := router.New()
+ r.GET("/:pos", router.MiddlewareChain{}, handler)
+
+ srv := httptest.NewServer(r)
+
+ client := crRevClient{
+ HTTPClient: &http.Client{},
+ BaseURL: srv.URL,
+ }
+
+ Convey("commitPositionToHash", t, func() {
+ Convey("existing position", func() {
+ hash, err := client.commitHash("1300")
+ So(err, ShouldBeNil)
+ So(hash, ShouldEqual, "0dfc81bbe403cd98f4cd2d58e7817cdc8a881a5f")
+ })
+
+ Convey("non-existent position", func() {
+ _, err := client.commitHash("0")
+ So(err, ShouldNotBeNil)
+ })
+ })
+}
« 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