Skip to content

Commit

Permalink
Revert "RSDK-8767 - populate local_name and remote_path to all resour… (
Browse files Browse the repository at this point in the history
  • Loading branch information
cheukt authored and 10zingpd committed Nov 21, 2024
1 parent 35c5906 commit 9255676
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 65 deletions.
10 changes: 4 additions & 6 deletions protoutils/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import (
// ResourceNameToProto converts a resource.Name to its proto counterpart.
func ResourceNameToProto(name resource.Name) *commonpb.ResourceName {
return &commonpb.ResourceName{
Namespace: string(name.API.Type.Namespace),
Type: name.API.Type.Name,
Subtype: name.API.SubtypeName,
Name: name.ShortName(),
RemotePath: name.RemoteNameToRemoteArray(),
LocalName: name.Name,
Namespace: string(name.API.Type.Namespace),
Type: name.API.Type.Name,
Subtype: name.API.SubtypeName,
Name: name.ShortName(),
}
}

Expand Down
17 changes: 0 additions & 17 deletions protoutils/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"go.viam.com/test"
"google.golang.org/protobuf/types/known/wrapperspb"

"go.viam.com/rdk/resource"
)

func TestStringToAnyPB(t *testing.T) {
Expand Down Expand Up @@ -42,18 +40,3 @@ func TestStringToAnyPB(t *testing.T) {
wrappedVal4 := wrapperspb.String("abcd")
test.That(t, anyVal.MessageIs(wrappedVal4), test.ShouldBeTrue)
}

func TestResourceNameToProto(t *testing.T) {
resourceName := resource.Name{
Name: "totallyLegitResource",
Remote: "remote1:remote2:remote3",
API: resource.NewAPI("space", "fake", "fakeFake"),
}
resourceNameProto := ResourceNameToProto(resourceName)
finalResource := ResourceNameFromProto(resourceNameProto)

test.That(t, resourceNameProto.LocalName, test.ShouldEqual, "totallyLegitResource")
test.That(t, resourceNameProto.RemotePath, test.ShouldResemble, []string{"remote1", "remote2", "remote3"})
test.That(t, resourceNameProto.Name, test.ShouldEqual, "remote1:remote2:remote3:totallyLegitResource")
test.That(t, finalResource, test.ShouldResemble, resourceName)
}
8 changes: 0 additions & 8 deletions resource/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ func (n Name) String() string {
return name
}

// RemoteNameToRemoteArray returns an ordered array of all of remotes in a resource name.
func (n Name) RemoteNameToRemoteArray() []string {
if n.Remote == "" {
return []string{}
}
return strings.Split(n.Remote, ":")
}

// SDPTrackName returns a valid SDP video/audio track name as defined in RFC 4566 (https://www.rfc-editor.org/rfc/rfc4566)
// where track names should not include colons.
func (n Name) SDPTrackName() string {
Expand Down
18 changes: 0 additions & 18 deletions resource/name_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,3 @@ func TestNamesToStrings(t *testing.T) {
test.That(t, NamesToStrings(tc.input), test.ShouldResemble, tc.output)
}
}

func TestRemoteNameToRemoteArray(t *testing.T) {
t.Run("name with multiple remote returns array of remotes", func(t *testing.T) {
nameTest := Name{
Remote: "foo:bar:wow",
}
remoteArray := nameTest.RemoteNameToRemoteArray()
test.That(t, remoteArray, test.ShouldResemble, []string{"foo", "bar", "wow"})
})

t.Run("name with empty remotes should return empty string array", func(t *testing.T) {
nameTest := Name{
Remote: "",
}
remoteArray := nameTest.RemoteNameToRemoteArray()
test.That(t, remoteArray, test.ShouldResemble, []string{})
})
}
26 changes: 10 additions & 16 deletions robot/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ var serverNewResource = arm.Named("")

var serverOneResourceResponse = []*commonpb.ResourceName{
{
Namespace: string(serverNewResource.API.Type.Namespace),
Type: serverNewResource.API.Type.Name,
Subtype: serverNewResource.API.SubtypeName,
Name: serverNewResource.Name,
RemotePath: []string{},
LocalName: "",
Namespace: string(serverNewResource.API.Type.Namespace),
Type: serverNewResource.API.Type.Name,
Subtype: serverNewResource.API.SubtypeName,
Name: serverNewResource.Name,
},
}

Expand Down Expand Up @@ -327,21 +325,17 @@ func TestServer(t *testing.T) {
expectedResp := []*pb.ResourceRPCSubtype{
{
Subtype: &commonpb.ResourceName{
Namespace: string(serverNewResource.API.Type.Namespace),
Type: serverNewResource.API.Type.Name,
Subtype: serverNewResource.API.SubtypeName,
RemotePath: []string{},
Name: "",
Namespace: string(serverNewResource.API.Type.Namespace),
Type: serverNewResource.API.Type.Name,
Subtype: serverNewResource.API.SubtypeName,
},
ProtoService: desc1.GetFullyQualifiedName(),
},
{
Subtype: &commonpb.ResourceName{
Namespace: string(otherAPI.Type.Namespace),
Type: otherAPI.Type.Name,
Subtype: otherAPI.SubtypeName,
RemotePath: []string{},
Name: "",
Namespace: string(otherAPI.Type.Namespace),
Type: otherAPI.Type.Name,
Subtype: otherAPI.SubtypeName,
},
ProtoService: desc2.GetFullyQualifiedName(),
},
Expand Down

0 comments on commit 9255676

Please sign in to comment.