dashboard/app: fix a bug with bugs with seq>0

See the added test.
This commit is contained in:
Dmitry Vyukov 2017-09-13 12:05:56 +02:00
parent 013a8d4c00
commit 06091e7473
2 changed files with 11 additions and 1 deletions

View File

@ -349,11 +349,12 @@ func apiReportCrash(c context.Context, ns string, r *http.Request) (interface{},
return nil, err
}
bug := new(Bug)
var bug *Bug
var bugKey *datastore.Key
tx := func(c context.Context) error {
for seq := int64(0); ; seq++ {
bug = new(Bug)
bugHash := bugKeyHash(ns, req.Title, seq)
bugKey = datastore.NewKey(c, "Bug", bugHash, 0, nil)
if err := datastore.Get(c, bugKey, bug); err != nil {

View File

@ -118,6 +118,15 @@ func TestFixBasic(t *testing.T) {
c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))
reports = reportAllBugs(c, 1)
c.expectEQ(reports[0].Title, "title1 (2)")
// Regression test: previously upstreamming failed because the new bug had fixing commits.
c.expectOK(c.API(client1, key1, "report_crash", crash1, nil))
cmd = &dashapi.BugUpdate{
ID: reports[0].ID,
Status: dashapi.BugStatusUpstream,
}
c.expectOK(c.API(client1, key1, "reporting_update", cmd, reply))
c.expectEQ(reply.OK, true)
}
// Test bug that is fixed by 2 commits.