replace t.Logf with log.Printf, replace t.Log with log.Print and add gopath to bin
This commit is contained in:
parent
aae5025f27
commit
b6d04dbae4
6
.github/workflows/go-workflow-1.yml
vendored
6
.github/workflows/go-workflow-1.yml
vendored
@ -22,6 +22,12 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
- name: Set GOPATH and PATH
|
||||||
|
run: |
|
||||||
|
echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)"
|
||||||
|
echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/bin"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
with:
|
with:
|
||||||
|
17
app_test.go
17
app_test.go
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@ -1422,7 +1423,7 @@ func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, flagSet := range subcommandHelpTopics {
|
for _, flagSet := range subcommandHelpTopics {
|
||||||
t.Logf("==> checking with flags %v", flagSet)
|
log.Printf("==> checking with flags %v", flagSet)
|
||||||
|
|
||||||
app := &App{}
|
app := &App{}
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
@ -1451,7 +1452,7 @@ func TestApp_Run_CommandWithSubcommandHasHelpTopic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output := buf.String()
|
output := buf.String()
|
||||||
//t.Logf("output: %q\n", buf.Bytes())
|
//log.Printf("output: %q\n", buf.Bytes())
|
||||||
|
|
||||||
if strings.Contains(output, "No help topic for") {
|
if strings.Contains(output, "No help topic for") {
|
||||||
t.Errorf("expect a help topic, got none: \n%q", output)
|
t.Errorf("expect a help topic, got none: \n%q", output)
|
||||||
@ -1613,7 +1614,7 @@ func TestApp_Run_Help(t *testing.T) {
|
|||||||
for _, args := range helpArguments {
|
for _, args := range helpArguments {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
t.Logf("==> checking with arguments %v", args)
|
log.Printf("==> checking with arguments %v", args)
|
||||||
|
|
||||||
app := &App{
|
app := &App{
|
||||||
Name: "boom",
|
Name: "boom",
|
||||||
@ -1631,7 +1632,7 @@ func TestApp_Run_Help(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output := buf.String()
|
output := buf.String()
|
||||||
t.Logf("output: %q\n", buf.Bytes())
|
log.Printf("output: %q\n", buf.Bytes())
|
||||||
|
|
||||||
if !strings.Contains(output, "boom - make an explosive entrance") {
|
if !strings.Contains(output, "boom - make an explosive entrance") {
|
||||||
t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output)
|
t.Errorf("want help to contain %q, did not: \n%q", "boom - make an explosive entrance", output)
|
||||||
@ -1645,7 +1646,7 @@ func TestApp_Run_Version(t *testing.T) {
|
|||||||
for _, args := range versionArguments {
|
for _, args := range versionArguments {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
t.Logf("==> checking with arguments %v", args)
|
log.Printf("==> checking with arguments %v", args)
|
||||||
|
|
||||||
app := &App{
|
app := &App{
|
||||||
Name: "boom",
|
Name: "boom",
|
||||||
@ -1664,7 +1665,7 @@ func TestApp_Run_Version(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output := buf.String()
|
output := buf.String()
|
||||||
t.Logf("output: %q\n", buf.Bytes())
|
log.Printf("output: %q\n", buf.Bytes())
|
||||||
|
|
||||||
if !strings.Contains(output, "0.1.0") {
|
if !strings.Contains(output, "0.1.0") {
|
||||||
t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output)
|
t.Errorf("want version to contain %q, did not: \n%q", "0.1.0", output)
|
||||||
@ -1718,7 +1719,7 @@ func TestApp_Run_Categories(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
output := buf.String()
|
output := buf.String()
|
||||||
//t.Logf("output: %q\n", buf.Bytes())
|
//log.Printf("output: %q\n", buf.Bytes())
|
||||||
|
|
||||||
if !strings.Contains(output, "1:\n command1") {
|
if !strings.Contains(output, "1:\n command1") {
|
||||||
t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output)
|
t.Errorf("want buffer to include category %q, did not: \n%q", "1:\n command1", output)
|
||||||
@ -2122,7 +2123,7 @@ func TestWhenExitSubCommandWithCodeThenAppQuitUnexpectedly(t *testing.T) {
|
|||||||
var exitCodeFromExitErrHandler int
|
var exitCodeFromExitErrHandler int
|
||||||
app.ExitErrHandler = func(c *Context, err error) {
|
app.ExitErrHandler = func(c *Context, err error) {
|
||||||
if exitErr, ok := err.(ExitCoder); ok {
|
if exitErr, ok := err.(ExitCoder); ok {
|
||||||
t.Log(exitErr)
|
log.Print(exitErr)
|
||||||
exitCodeFromExitErrHandler = exitErr.ExitCode()
|
exitCodeFromExitErrHandler = exitErr.ExitCode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user