-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
33 lines (27 loc) · 856 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//go:build e2e
// +build e2e
// Copyright (c) 2022 Red Hat, Inc.
// Copyright Contributors to the Open Cluster Management project
package main
import (
"os"
"os/signal"
"syscall"
"testing"
)
// TestRunMain wraps the main() function in order to build a test binary and collection coverage for
// E2E/Integration tests. Controller CLI flags are also passed in here.
func TestRunMain(t *testing.T) {
// Modifying the args seems necessary to make the test binary and cobra happy.
os.Args = append([]string{
"governance-policy-addon-controller",
"controller",
"--namespace=governance-policy-addon-controller-system",
}, os.Args[1:]...)
// Run main in a separate goroutine
go main()
// The test will end (and pass) via an external signal
stopHandler := make(chan os.Signal, 1)
signal.Notify(stopHandler, syscall.SIGUSR1)
<-stopHandler
}