Skip to content

Commit

Permalink
[wrap] add test for message truncation
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Apr 16, 2019
1 parent 7c13398 commit a109ff5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
13 changes: 13 additions & 0 deletions wrap/testdata/long.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
"fmt"
"os"
)

func main() {
for i := 0; i < 100; i++ {
fmt.Println("Hello world!")
}
os.Exit(1)
}
24 changes: 24 additions & 0 deletions wrap/wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ Note: This is note
% go run testdata/stub.go
Hello.
exit status 1
`,
NotificationInterval: 0,
},
ExitCode: 1,
},
{
Name: "long output",
Args: []string{
"-name=test-check",
"-detail",
"-note", "This is note",
"--",
"go", "run", "testdata/long.go",
},
Result: testResult{
Name: "test-check",
Status: mackerel.CheckStatusCritical,
Message: `command exited with code: 1
Note: This is note
% go run testdata/long.go
` + strings.Repeat("Hello world!\n", 33) + `Hello w
...
!
` + strings.Repeat("Hello world!\n", 38) + `exit status 1
`,
NotificationInterval: 0,
},
Expand Down

0 comments on commit a109ff5

Please sign in to comment.