go: add more tests (+return instead of exit)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-05-03 04:26:42 +02:00
parent 1ba95c3d37
commit ed14e45969
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ
2 changed files with 26 additions and 1 deletions

2
run.go
View File

@ -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
View 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()
}