mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
fixes #914
This commit is contained in:
parent
833b5af087
commit
f734bd0b60
2 changed files with 9 additions and 9 deletions
|
@ -38,10 +38,10 @@ type Build struct {
|
|||
// Trim trims string values that would otherwise exceed
|
||||
// the database column sizes and fail to insert.
|
||||
func (b *Build) Trim() {
|
||||
if len(b.Title) > 500 {
|
||||
b.Title = b.Title[:500]
|
||||
if len(b.Title) > 1000 {
|
||||
b.Title = b.Title[:1000]
|
||||
}
|
||||
if len(b.Message) > 500 {
|
||||
b.Message = b.Message[:500]
|
||||
if len(b.Message) > 2000 {
|
||||
b.Message = b.Message[:2000]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,17 +7,17 @@ import (
|
|||
)
|
||||
|
||||
func TestBuildTrim(t *testing.T) {
|
||||
d := make([]byte, 1000)
|
||||
d := make([]byte, 2000)
|
||||
rand.Read(d)
|
||||
|
||||
b := Build{}
|
||||
b.Message = fmt.Sprintf("%X", d)
|
||||
|
||||
if len(b.Message) != 2000 {
|
||||
t.Errorf("Failed to generate 2000 byte test string")
|
||||
if len(b.Message) != 4000 {
|
||||
t.Errorf("Failed to generate 4000 byte test string")
|
||||
}
|
||||
b.Trim()
|
||||
if len(b.Message) != 500 {
|
||||
t.Errorf("Failed to trim text string to 500 bytes")
|
||||
if len(b.Message) != 2000 {
|
||||
t.Errorf("Failed to trim text string to 2000 bytes")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue