From 6abbac6c2d61e190cd90081143763a8860bb6d0d Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Fri, 8 Apr 2022 10:40:01 +0200 Subject: [PATCH] Add integration test ability to provider --- cmd/csaf_provider/main_test.go | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 cmd/csaf_provider/main_test.go diff --git a/cmd/csaf_provider/main_test.go b/cmd/csaf_provider/main_test.go new file mode 100644 index 0000000..0195333 --- /dev/null +++ b/cmd/csaf_provider/main_test.go @@ -0,0 +1,36 @@ +package main + +import ( + "os" + "testing" +) + +// as main() does not process os.Args, we can call it directly as -test.* +// parameters will be ignored. +// +// use like +// go test -c -vet=off -covermode=atomic -o csaf_provider.debug +// cp csaf_provider.debug /usr/lib/cgi-bin/ +// +// pushd /usr/lib/cgi-bin +// mv csaf_provider.go csaf_provider2.go +// echo '#!/bin/bash +// exec /usr/lib/cgi-bin/csaf_provider.debug -test.coverprofile=/tmp/csaf_provider-itest.cov -- "$@" +// ' >csaf_provider.go +// chmod a+x csaf_provider.go +// +// then do a cgi-bin action on the provider like using the uploader + +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") + } + main() +}