Add per project rate limit

This commit is contained in:
simon987
2019-02-24 21:18:55 -05:00
parent 9acf6e27c1
commit 3415f95337
13 changed files with 347 additions and 267 deletions

View File

@@ -13,14 +13,16 @@ import (
func TestCreateGetProject(t *testing.T) {
resp := createProjectAsAdmin(api.CreateProjectRequest{
Name: "Test name",
CloneUrl: "http://github.com/test/test",
GitRepo: "drone/webhooktest",
Version: "Test Version",
Priority: 123,
Motd: "motd",
Public: true,
Hidden: false,
Name: "Test name",
CloneUrl: "http://github.com/test/test",
GitRepo: "drone/webhooktest",
Version: "Test Version",
Priority: 123,
Motd: "motd",
Public: true,
Hidden: false,
AssignRate: 10.0,
SubmitRate: 20.0,
})
id := resp.Content.Id
@@ -64,6 +66,12 @@ func TestCreateGetProject(t *testing.T) {
if getResp.Project.Hidden != false {
t.Error()
}
if getResp.Project.SubmitRate != 20.0 {
t.Error()
}
if getResp.Project.AssignRate != 10.0 {
t.Error()
}
}
func TestCreateProjectInvalid(t *testing.T) {
@@ -107,24 +115,28 @@ func TestGetProjectNotFound(t *testing.T) {
func TestUpdateProjectValid(t *testing.T) {
pid := createProjectAsAdmin(api.CreateProjectRequest{
Public: true,
Version: "versionA",
Motd: "MotdA",
Name: "NameA",
CloneUrl: "CloneUrlA",
GitRepo: "GitRepoA",
Priority: 1,
Public: true,
Version: "versionA",
Motd: "MotdA",
Name: "NameA",
CloneUrl: "CloneUrlA",
GitRepo: "GitRepoA",
Priority: 1,
AssignRate: 3,
SubmitRate: 3,
}).Content.Id
updateResp := updateProject(api.UpdateProjectRequest{
Priority: 2,
GitRepo: "GitRepoB",
CloneUrl: "CloneUrlB",
Name: "NameB",
Motd: "MotdB",
Public: false,
Hidden: true,
Paused: true,
Priority: 2,
GitRepo: "GitRepoB",
CloneUrl: "CloneUrlB",
Name: "NameB",
Motd: "MotdB",
Public: false,
Hidden: true,
Paused: true,
AssignRate: 1,
SubmitRate: 2,
}, pid, testAdminCtx)
if updateResp.Ok != true {
@@ -154,6 +166,12 @@ func TestUpdateProjectValid(t *testing.T) {
if proj.Project.Paused != true {
t.Error()
}
if proj.Project.AssignRate != 1 {
t.Error()
}
if proj.Project.SubmitRate != 2 {
t.Error()
}
}
func TestUpdateProjectInvalid(t *testing.T) {