Skip to content

Commit

Permalink
add provisioningclient tests to viam client test
Browse files Browse the repository at this point in the history
  • Loading branch information
purplenicole730 committed Nov 21, 2024
1 parent aff5ebb commit a8b4407
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/viam_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"testing"

"github.com/viamrobotics/webrtc/v3"
pb "go.viam.com/api/app/data/v1"
datapb "go.viam.com/api/app/data/v1"
provisioningpb "go.viam.com/api/provisioning/v1"
"go.viam.com/test"
"go.viam.com/utils"
"go.viam.com/utils/rpc"
Expand Down Expand Up @@ -119,7 +120,7 @@ func TestCreateViamClientWithAPIKeyTests(t *testing.T) {
}
}

func TestNewDataClient(t *testing.T) {
func TestNewAppClients(t *testing.T) {
originalDialDirectGRPC := dialDirectGRPC
dialDirectGRPC = mockDialDirectGRPC
defer func() { dialDirectGRPC = originalDialDirectGRPC }()
Expand All @@ -138,10 +139,20 @@ func TestNewDataClient(t *testing.T) {
dataClient := client.DataClient()
test.That(t, dataClient, test.ShouldNotBeNil)
test.That(t, dataClient, test.ShouldHaveSameTypeAs, &DataClient{})
test.That(t, dataClient.client, test.ShouldImplement, (*pb.DataServiceClient)(nil))
test.That(t, dataClient.client, test.ShouldImplement, (*datapb.DataServiceClient)(nil))

// Testing that a second call to DataClient() returns the same instance
dataClient2 := client.DataClient()
test.That(t, dataClient2, test.ShouldNotBeNil)
test.That(t, dataClient, test.ShouldResemble, dataClient2)
test.That(t, dataClient, test.ShouldEqual, dataClient2)

provisioningClient := client.ProvisioningClient()
test.That(t, provisioningClient, test.ShouldNotBeNil)
test.That(t, provisioningClient, test.ShouldHaveSameTypeAs, &ProvisioningClient{})
test.That(t, provisioningClient.client, test.ShouldImplement, (*provisioningpb.ProvisioningServiceClient)(nil))

// Testing that a second call to ProvisioningClient() returns the same instance
provisioningClient2 := client.ProvisioningClient()
test.That(t, provisioningClient2, test.ShouldNotBeNil)
test.That(t, provisioningClient, test.ShouldEqual, provisioningClient2)
}

0 comments on commit a8b4407

Please sign in to comment.