diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-01-23 21:54:41 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-27 10:05:21 +0000 |
| commit | 2bf68614de1620ef12f086d9e86d5c8b334bf32d (patch) | |
| tree | 24b69669a1ee44c1a34988d917cb248faed40cd3 /dashboard/app/handler.go | |
| parent | 0868754a9d325ba9011e1cb74510f68d4b627c79 (diff) | |
dashboard/app: test coverage /file link
1. Init coveragedb client once and propagate it through context to enable mocking.
2. Always init coverage handlers. It simplifies testing.
3. Read webGit and coveragedb client from ctx to make it mockable.
4. Use int for file line number and int64 for merged coverage.
5. Add tests.
Diffstat (limited to 'dashboard/app/handler.go')
| -rw-r--r-- | dashboard/app/handler.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go index e737c2b0b..27817ab8c 100644 --- a/dashboard/app/handler.go +++ b/dashboard/app/handler.go @@ -32,6 +32,9 @@ func handlerWrapper(fn contextHandler) http.Handler { func handleContext(fn contextHandler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c := appengine.NewContext(r) + if coverageDBClient != nil { // Nil in prod. + c = SetCoverageDBClient(c, coverageDBClient) + } c = context.WithValue(c, ¤tURLKey, r.URL.RequestURI()) authorizedUser, _ := userAccessLevel(currentUser(c), "", getConfig(c)) if !authorizedUser { |
