go: add more tests (+return instead of exit)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1ba95c3d37
commit
ed14e45969
2
run.go
2
run.go
@ -65,7 +65,7 @@ func run() error {
|
||||
|
||||
if *license {
|
||||
fmt.Fprintln(os.Stderr, licenseHeader)
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
printHeader()
|
||||
|
25
run_test.go
Normal file
25
run_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPrintLicense(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Log("print license and exit")
|
||||
|
||||
if err := flag.Set("license", "true"); err != nil {
|
||||
t.Fatal("failed to set license flag")
|
||||
}
|
||||
|
||||
err := run()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPrintHeader(t *testing.T) {
|
||||
t.Parallel()
|
||||
printHeader()
|
||||
}
|
Loading…
Reference in New Issue
Block a user