github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/fitapp/Edit_test.go (about) 1 package fitapp 2 3 import ( 4 "fmt" 5 bugs "github.com/grantbow/fit/issues" 6 "regexp" 7 "testing" 8 ) 9 10 func TestEditInvalid(t *testing.T) { 11 config := bugs.Config{} 12 stdout, stderr := captureOutput(func() { 13 Edit(argumentList{"Test"}, config) 14 }, t) 15 if stderr != "" { 16 t.Error("Unexpected error:") 17 fmt.Printf("Expected: %s\nGot %s\n", "", stderr) 18 } 19 expected := "Invalid IssueID Test\n" 20 if stdout != expected { 21 t.Error("Unexpected output on STDOUT") 22 fmt.Printf("Expected: %s\nGot %s\n", expected, stdout) 23 } 24 25 stdout, stderr = captureOutput(func() { 26 Edit(argumentList{"a", "b", "c"}, config) 27 }, t) 28 if stderr != "" { 29 t.Error("Unexpected error:") 30 fmt.Printf("Expected: %s\nGot %s\n", "", stderr) 31 } 32 expected = "Usage.* edit \\[fieldname\\] IssueID\n\nNo IssueID specified\n" 33 re := regexp.MustCompile(expected) 34 matched := re.MatchString(string(stdout)) 35 if !matched { 36 t.Error("Unexpected output on STDOUT for fitapp/Commit_test") 37 fmt.Printf("Expected: %s\nGot: %s\n", expected, stdout) 38 } 39 }