1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

Add coverage for integration test to checker

This commit is contained in:
Bernhard Reiter 2022-04-13 15:18:32 +02:00
parent 85447c20b7
commit 7a1d26e3fd
No known key found for this signature in database
GPG key ID: 2B7BA3BF9BC3A554
2 changed files with 30 additions and 2 deletions

View file

@ -353,12 +353,12 @@ func check(err error) {
}
}
func main() {
func realMain(args []string) {
var opts options
parser := flags.NewParser(&opts, flags.Default)
args, err := parser.Parse()
args, err := parser.ParseArgs(args)
check(err)
if opts.Version {
@ -407,3 +407,7 @@ func main() {
check(p.process(arg))
}
}
func main() {
realMain(os.Args[1:])
}

View file

@ -0,0 +1,24 @@
package main
import (
"os"
"testing"
)
// call realMain() with Args that skip over params used by "go test"
// allow calls like
// go test -c -vet=off -covermode=atomic -o csaf_uploader.debug
// ./csaf_uploader.debug -test.coverprofile=/tmp/csaf_uploader-itest-${EPOCHREALTIME}.cov -- --insecure ....
func TestMain(t *testing.T) {
var endOfTestParams int
for i, a := range os.Args[1:] {
if a == "--" {
endOfTestParams = i + 1
}
}
if endOfTestParams == 0 {
t.Skip("skipping integration test, no `--` parameter found")
}
realMain(os.Args[endOfTestParams+1:])
}