mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-08-31 15:15:28 +00:00
fixes #914
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user