Newer
Older
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
34
35
36
37
38
39
package integration_test_example
import (
"context"
"fmt"
"testing"
integration_test_utils "code.fbi.h-da.de/danet/gosdn/integration-tests/integrationTestUtils"
"google.golang.org/grpc"
)
// The connection to the controller to use in each test.
var conn *grpc.ClientConn
// The context containing the credentials when authenticated.
var ctx context.Context
// A defaultSDN config with default/empty values.
var defaultSDNConfig string
func TestMain(m *testing.M) {
localConn, localCtx, err := integration_test_utils.CreateSecureConnection()
if err != nil {
fmt.Println(err.Error())
}
conn = localConn
ctx = localCtx
sndConfig, err := integration_test_utils.ExportCurrentSDNConfig(conn, ctx)
defaultSDNConfig = sndConfig
if err != nil {
fmt.Println(err.Error())
}
m.Run()
}
func TestExample(t *testing.T) {
defer integration_test_utils.ApplySDNConfig(conn, ctx, defaultSDNConfig)
// You can set the environment to a different sdn config like this:
// integration_test_utils.ApplySDNConfig(connection, ctx, customSDNConfig)