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

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

Issue 2234353002: test-results: package model: Add full_result.go and tests (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Improve coverage 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 | « no previous file | go/src/infra/appengine/test-results/model/aggregate_result.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package frontend 1 package frontend
2 2
3 import ( 3 import (
4 "bytes" 4 "bytes"
5 "encoding/json" 5 "encoding/json"
6 "fmt" 6 "fmt"
7 "infra/appengine/test-results/model" 7 "infra/appengine/test-results/model"
8 "io" 8 "io"
9 "net/http" 9 "net/http"
10 "regexp" 10 "regexp"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 202 }
203 203
204 if err := tf.GetData(c); err != nil { 204 if err := tf.GetData(c); err != nil {
205 http.Error(w, err.Error(), http.StatusInternalServerError) 205 http.Error(w, err.Error(), http.StatusInternalServerError)
206 return 206 return
207 } 207 }
208 208
209 finalData := tf.Data 209 finalData := tf.Data
210 210
211 if params.TestListJSON { 211 if params.TestListJSON {
212 data, err := model.CleanJSON(tf.Data)
213 if err != nil {
214 http.Error(w, err.Error(), http.StatusInternalServerErro r)
215 logging.Errorf(c, "failed to clean test results JSON: %v ", err)
216 return
217 }
212 aggr := model.AggregateResult{Builder: params.Builder} 218 aggr := model.AggregateResult{Builder: params.Builder}
213 » » if err := json.NewDecoder(tf.Data).Decode(&aggr); err != nil { 219 » » if err := json.NewDecoder(data).Decode(&aggr); err != nil {
214 http.Error(w, err.Error(), http.StatusInternalServerErro r) 220 http.Error(w, err.Error(), http.StatusInternalServerErro r)
215 » » » logging.Errorf(c, "failed to unmarshal TestResults JSON: %+v: %v", tf.Data, err) 221 » » » logging.Errorf(c, "failed to unmarshal test results JSON : %+v: %v", data, err)
216 return 222 return
217 } 223 }
218 aggr.Tests.ToTestList() 224 aggr.Tests.ToTestList()
219 buf := &bytes.Buffer{} 225 buf := &bytes.Buffer{}
220 if err := json.NewEncoder(buf).Encode(aggr.Tests); err != nil { 226 if err := json.NewEncoder(buf).Encode(aggr.Tests); err != nil {
221 http.Error(w, err.Error(), http.StatusInternalServerErro r) 227 http.Error(w, err.Error(), http.StatusInternalServerErro r)
222 logging.Errorf(c, "failed to marshal test list JSON: %+v , %v", aggr.Tests, err) 228 logging.Errorf(c, "failed to marshal test list JSON: %+v , %v", aggr.Tests, err)
223 return 229 return
224 } 230 }
225 finalData = buf 231 finalData = buf
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 273 }
268 } 274 }
269 275
270 // wrapCallback returns an io.Reader that wraps the data in r in a 276 // wrapCallback returns an io.Reader that wraps the data in r in a
271 // JavaScript-style function call with the supplied name as the function name. 277 // JavaScript-style function call with the supplied name as the function name.
272 func wrapCallback(r io.Reader, name string) io.Reader { 278 func wrapCallback(r io.Reader, name string) io.Reader {
273 start := bytes.NewReader([]byte(name + "(")) 279 start := bytes.NewReader([]byte(name + "("))
274 end := bytes.NewReader([]byte(");")) 280 end := bytes.NewReader([]byte(");"))
275 return io.MultiReader(start, r, end) 281 return io.MultiReader(start, r, end)
276 } 282 }
OLDNEW
« no previous file with comments | « no previous file | go/src/infra/appengine/test-results/model/aggregate_result.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698