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

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

Issue 2355353002: Return 409 error when uploading build with same number again (Closed)
Patch Set: Fix Created 4 years, 2 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/upload.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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package frontend 5 package frontend
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "infra/appengine/test-results/model" 10 "infra/appengine/test-results/model"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 reader, err := tf.DataReader(ctx) 253 reader, err := tf.DataReader(ctx)
254 So(err, ShouldBeNil) 254 So(err, ShouldBeNil)
255 var updated model.AggregateResult 255 var updated model.AggregateResult
256 So(json.NewDecoder(reader).Decode(&updated), Sho uldBeNil) 256 So(json.NewDecoder(reader).Decode(&updated), Sho uldBeNil)
257 257
258 // TODO(nishanths): also check `updated` ShouldR esemble `expected`. 258 // TODO(nishanths): also check `updated` ShouldR esemble `expected`.
259 }) 259 })
260 }) 260 })
261 }) 261 })
262 } 262 }
263
264 func TestUses409ResponseCodeForBuildNumberConflict(t *testing.T) {
265 t.Parallel()
266
267 Convey("Return HTTP response code 409 for build with same number", t, fu nc() {
268 ctx := memory.Use(context.Background())
269 testFileIdx, err := datastore.FindAndParseIndexYAML(
270 filepath.Join("testdata"))
271 if err != nil {
272 panic(err)
273 }
274 datastore.GetTestable(ctx).AddIndexes(testFileIdx...)
275 datastore.GetTestable(ctx).CatchupIndexes()
276
277 ctx = SetUploadParams(ctx, &UploadParams{
278 Master: "foo",
279 Builder: "bar",
280 TestType: "baz",
281 })
282 data, err := ioutil.ReadFile(
283 filepath.Join("testdata", "full_results_0.json"))
284 data = bytes.TrimSpace(data)
285 So(err, ShouldBeNil)
286
287 So(updateFullResults(ctx, bytes.NewReader(data)), ShouldBeNil)
288
289 // Ensure that the file is saved in datastore. See http://crbug. com/648817.
290 datastore.GetTestable(ctx).CatchupIndexes()
291
292 err = updateFullResults(ctx, bytes.NewReader(data))
293 se, ok := err.(statusError)
294 So(ok, ShouldBeTrue)
295 So(se.code, ShouldEqual, 409)
296 })
297 }
OLDNEW
« no previous file with comments | « go/src/infra/appengine/test-results/frontend/upload.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698