mirror of
https://github.com/go-gitea/gitea
synced 2024-09-12 09:26:56 +02:00
Add test for NewBoard
This commit is contained in:
parent
da28c1c3a4
commit
ed56a0f5fc
@ -4,6 +4,8 @@
|
|||||||
package project
|
package project
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
@ -98,3 +100,26 @@ func Test_MoveColumnsOnProject(t *testing.T) {
|
|||||||
assert.EqualValues(t, columns[2].ID, columnsAfter[1].ID)
|
assert.EqualValues(t, columns[2].ID, columnsAfter[1].ID)
|
||||||
assert.EqualValues(t, columns[0].ID, columnsAfter[2].ID)
|
assert.EqualValues(t, columns[0].ID, columnsAfter[2].ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_NewBoard(t *testing.T) {
|
||||||
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
|
||||||
|
project1 := unittest.AssertExistsAndLoadBean(t, &Project{ID: 1})
|
||||||
|
columns, err := project1.GetBoards(db.DefaultContext)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Len(t, columns, 3)
|
||||||
|
|
||||||
|
for i := 0; i < maxProjectColumns-3; i++ {
|
||||||
|
err := NewBoard(db.DefaultContext, &Board{
|
||||||
|
Title: fmt.Sprintf("board-%d", i+4),
|
||||||
|
ProjectID: project1.ID,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
err = NewBoard(db.DefaultContext, &Board{
|
||||||
|
Title: "board-21",
|
||||||
|
ProjectID: project1.ID,
|
||||||
|
})
|
||||||
|
assert.Error(t, err)
|
||||||
|
assert.True(t, strings.Contains(err.Error(), "maximum number of columns reached"))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user