Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer resource diff in tests for VerifySameResources #4389

Merged

Conversation

maximpertsov
Copy link
Contributor

@maximpertsov maximpertsov commented Sep 24, 2024

Pulled out of #4273 - provides a more concise diff of resources when the test utility VerifySameResources fails. The current (verbose) diff is still included in the failure output.

Example output

# current (verbose)
robot_reconfigure_remote_test.go:143: Expected: '[]resource.Name{resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"", Name:"arm1"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"foo", Name:"remoteArm"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"foo", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"foo", Name:"builtin"}}'
        Actual:   '[]resource.Name{resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"", Name:"arm1"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"foo", Name:"remoteArm"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"remote"}, SubtypeName:""}, Remote:"", Name:"foo"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"foo", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"foo", Name:"builtin"}}'
        (Should resemble)!
        Diff:     '[]resource.Name{resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"", Name:"arm1"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"component"}, SubtypeName:"arm"}, Remote:"foo", Name:"remoteArm"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"remote"}, SubtypeName:""}, Remote:"", Name:"foo"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"motion"}, Remote:"foo", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"", Name:"builtin"}, resource.Name{API:resource.API{Type:resource.APIType{Namespace:resource.APINamespace("rdk"), Name:"service"}, SubtypeName:"sensors"}, Remote:"foo", Name:"builtin"}}'
      
# added (concise)
    resource_utils.go:92: Resource names do not match - see diff below: (-expected +actual)
         [
          "rdk:component:arm/arm1",
          "rdk:component:arm/foo:remoteArm",
        + "rdk:remote:/foo",
          "rdk:service:motion/builtin",
          "rdk:service:motion/foo:builtin",
          "rdk:service:sensors/builtin",
          "rdk:service:sensors/foo:builtin",
         ]

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Sep 24, 2024
@maximpertsov maximpertsov requested a review from a team September 24, 2024 18:26
@maximpertsov maximpertsov merged commit 1dc1119 into viamrobotics:main Sep 24, 2024
19 checks passed
@maximpertsov maximpertsov deleted the betterresourcedebugdiff branch September 24, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants