Skip to content
Snippets Groups Projects
Commit 8dc16cb6 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

fix unit tests

parent bd052834
No related branches found
No related tags found
1 merge request!821[renovate] Update module google.golang.org/grpc to v1.63.0
Pipeline #188578 passed
......@@ -9,10 +9,13 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/store"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"google.golang.org/grpc/resolver"
)
func Test_Init(t *testing.T) {
viper.SetConfigFile("./api_test.toml")
resolver.SetDefaultScheme("passthrough")
if err := Init(context.TODO(), bufnet); err != nil {
t.Error(err)
}
......
......@@ -18,6 +18,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/status"
"google.golang.org/grpc/test/bufconn"
)
......@@ -68,6 +69,7 @@ func getTestAuthInterceptorServer(t *testing.T) (*AuthInterceptor, *UserServer,
}
func dialer(interceptorServer *AuthInterceptor, userServer *UserServer, roleServer *RoleServer, pluginServer *PluginInternalServer) func(context.Context, string) (net.Conn, error) {
resolver.SetDefaultScheme("passthrough")
listener := bufconn.Listen(1024 * 1024)
interceptor := interceptorServer
......@@ -99,16 +101,16 @@ func TestAuthInterceptor_Unary(t *testing.T) {
t.Fatal(err)
}
ctx := context.Background()
conn, err := grpc.DialContext(
ctx,
"",
dialerFunc := dialer(authServer, userServer, roleServer, pluginServer)
conn, err := grpc.NewClient("bufnet",
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithContextDialer(dialer(authServer, userServer, roleServer, pluginServer)),
grpc.WithContextDialer(dialerFunc),
)
if err != nil {
t.Fatal(err)
}
defer func() {
if err := conn.Close(); err != nil {
log.Fatal(err)
......@@ -197,16 +199,16 @@ func TestAuthInterceptor_Stream(t *testing.T) {
t.Fatal(err)
}
ctx := context.Background()
conn, err := grpc.DialContext(
ctx,
"",
dialerFunc := dialer(authServer, userServer, roleServer, pluginServer)
conn, err := grpc.NewClient("bufnet",
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithContextDialer(dialer(authServer, userServer, roleServer, pluginServer)),
grpc.WithContextDialer(dialerFunc),
)
if err != nil {
t.Fatal(err)
}
defer func() {
if err := conn.Close(); err != nil {
log.Fatal(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment