aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/access_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-06-11 10:02:46 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-06-11 12:12:01 +0300
commit952c7994534bbc8f8134fc9c4130ff569dbbdbdf (patch)
tree4bc29eb7549a13b2408732b0a49fe33dce66d192 /dashboard/app/access_test.go
parentd6ae9b97396cde206f3d294594cd4a8fd55e3c63 (diff)
dashboard/app: refactor tests
Use standard dashboard client provided by dashapi package in tests. Switch everything to use the client instead of API method. Fixes #606
Diffstat (limited to 'dashboard/app/access_test.go')
-rw-r--r--dashboard/app/access_test.go62
1 files changed, 29 insertions, 33 deletions
diff --git a/dashboard/app/access_test.go b/dashboard/app/access_test.go
index 5918d3694..bc03ec9eb 100644
--- a/dashboard/app/access_test.go
+++ b/dashboard/app/access_test.go
@@ -178,10 +178,10 @@ func TestAccess(t *testing.T) {
clientName, clientKey = k, v
}
namespaceAccessPrefix := accessLevelPrefix(config.Namespaces[ns].AccessLevel)
- client := c.makeClient(clientName, clientKey)
+ client := c.makeClient(clientName, clientKey, true)
build := testBuild(1)
build.KernelConfig = []byte(namespaceAccessPrefix + "build")
- client.uploadBuild(build)
+ client.UploadBuild(build)
noteBuildccessLevel(ns, build.ID)
for reportingIdx := 0; reportingIdx < 2; reportingIdx++ {
@@ -189,36 +189,34 @@ func TestAccess(t *testing.T) {
accessPrefix := accessLevelPrefix(accessLevel)
crashInvalid := testCrashWithRepro(build, reportingIdx*10+0)
- client.reportCrash(crashInvalid)
- repInvalid := reportAllBugs(c, 1)[0]
+ client.ReportCrash(crashInvalid)
+ repInvalid := client.pollBug()
if reportingIdx != 0 {
- c.expectTrue(client.updateBug(repInvalid.ID, dashapi.BugStatusUpstream, "").OK)
- repInvalid = reportAllBugs(c, 1)[0]
+ client.updateBug(repInvalid.ID, dashapi.BugStatusUpstream, "")
+ repInvalid = client.pollBug()
}
- c.expectTrue(client.updateBug(repInvalid.ID, dashapi.BugStatusInvalid, "").OK)
+ client.updateBug(repInvalid.ID, dashapi.BugStatusInvalid, "")
noteBugAccessLevel(repInvalid.ID, accessLevel)
crashFixed := testCrashWithRepro(build, reportingIdx*10+0)
- client.reportCrash(crashFixed)
- repFixed := reportAllBugs(c, 1)[0]
+ client.ReportCrash(crashFixed)
+ repFixed := client.pollBug()
if reportingIdx != 0 {
- c.expectTrue(client.updateBug(repFixed.ID, dashapi.BugStatusUpstream, "").OK)
- repFixed = reportAllBugs(c, 1)[0]
+ client.updateBug(repFixed.ID, dashapi.BugStatusUpstream, "")
+ repFixed = client.pollBug()
}
- cmd := &dashapi.BugUpdate{
+ reply, _ := client.ReportingUpdate(&dashapi.BugUpdate{
ID: repFixed.ID,
Status: dashapi.BugStatusOpen,
FixCommits: []string{ns + "-patch0"},
ExtID: accessPrefix + "reporting-ext-id",
Link: accessPrefix + "reporting-link",
- }
- reply := new(dashapi.BugUpdateReply)
- client.expectOK(client.API("reporting_update", cmd, reply))
+ })
c.expectEQ(reply.OK, true)
buildFixing := testBuild(reportingIdx*10 + 2)
buildFixing.Manager = build.Manager
buildFixing.Commits = []string{ns + "-patch0"}
- client.uploadBuild(buildFixing)
+ client.UploadBuild(buildFixing)
noteBuildccessLevel(ns, buildFixing.ID)
// Fixed bugs become visible up to the last reporting.
finalLevel := config.Namespaces[ns].
@@ -230,42 +228,40 @@ func TestAccess(t *testing.T) {
crashOpen.Report = []byte(accessPrefix + "report")
crashOpen.ReproC = []byte(accessPrefix + "repro c")
crashOpen.ReproSyz = []byte(accessPrefix + "repro syz")
- client.reportCrash(crashOpen)
- repOpen := reportAllBugs(c, 1)[0]
+ client.ReportCrash(crashOpen)
+ repOpen := client.pollBug()
if reportingIdx != 0 {
- c.expectTrue(client.updateBug(repOpen.ID, dashapi.BugStatusUpstream, "").OK)
- repOpen = reportAllBugs(c, 1)[0]
+ client.updateBug(repOpen.ID, dashapi.BugStatusUpstream, "")
+ repOpen = client.pollBug()
}
noteBugAccessLevel(repOpen.ID, accessLevel)
crashPatched := testCrashWithRepro(build, reportingIdx*10+1)
- client.reportCrash(crashPatched)
- repPatched := reportAllBugs(c, 1)[0]
+ client.ReportCrash(crashPatched)
+ repPatched := client.pollBug()
if reportingIdx != 0 {
- c.expectTrue(client.updateBug(repPatched.ID, dashapi.BugStatusUpstream, "").OK)
- repPatched = reportAllBugs(c, 1)[0]
+ client.updateBug(repPatched.ID, dashapi.BugStatusUpstream, "")
+ repPatched = client.pollBug()
}
- cmd = &dashapi.BugUpdate{
+ reply, _ = client.ReportingUpdate(&dashapi.BugUpdate{
ID: repPatched.ID,
Status: dashapi.BugStatusOpen,
FixCommits: []string{ns + "-patch0"},
ExtID: accessPrefix + "reporting-ext-id",
Link: accessPrefix + "reporting-link",
- }
- reply = new(dashapi.BugUpdateReply)
- client.expectOK(client.API("reporting_update", cmd, reply))
+ })
c.expectEQ(reply.OK, true)
// Patched bugs are also visible up to the last reporting.
noteBugAccessLevel(repPatched.ID, finalLevel)
crashDup := testCrashWithRepro(build, reportingIdx*10+2)
- client.reportCrash(crashDup)
- repDup := reportAllBugs(c, 1)[0]
+ client.ReportCrash(crashDup)
+ repDup := client.pollBug()
if reportingIdx != 0 {
- c.expectTrue(client.updateBug(repDup.ID, dashapi.BugStatusUpstream, "").OK)
- repDup = reportAllBugs(c, 1)[0]
+ client.updateBug(repDup.ID, dashapi.BugStatusUpstream, "")
+ repDup = client.pollBug()
}
- c.expectTrue(client.updateBug(repDup.ID, dashapi.BugStatusDup, repOpen.ID).OK)
+ client.updateBug(repDup.ID, dashapi.BugStatusDup, repOpen.ID)
noteBugAccessLevel(repDup.ID, accessLevel)
}
}