Skip to content

Commit

Permalink
fixes harness#914
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed May 14, 2017
1 parent 833b5af commit f734bd0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions model/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
}
10 changes: 5 additions & 5 deletions model/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit f734bd0

Please sign in to comment.