Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Jul 5, 2024
1 parent 8a22601 commit 043face
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/networkservice/common/monitor/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,12 @@ func TestMonitorServer_Connection(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

// Create a grpc connection to non existing address
cc, err := grpc.Dial("1.1.1.1:5000", grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(t, err)
require.NotNil(t, cc)

// Create monitorServer, monitorClient, and server.
// Create a server
var monitorServer networkservice.MonitorConnectionServer
server := chain.NewNetworkServiceServer(
metadata.NewServer(),
Expand All @@ -233,14 +234,10 @@ func TestMonitorServer_Connection(t *testing.T) {
Connection: &networkservice.Connection{Id: "id"},
}

// Make a request that should be successful and immediate (because monitor server connects to 1.1.1.1:5000 in background)
conn, err := server.Request(ctx, request)
require.NoError(t, err)
require.NotNil(t, conn)

monitorClient := adapters.NewMonitorServerToClient(monitorServer)
client, err := monitorClient.MonitorConnections(ctx, &networkservice.MonitorScopeSelector{})
require.NoError(t, err)
require.NotNil(t, client)
}

type metricsServer struct{}
Expand Down

0 comments on commit 043face

Please sign in to comment.