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

Unable to unmarshal BoolVal to Yempty (GNMIEncoding) #291

Open
cho-m opened this issue Jul 7, 2019 · 0 comments · May be fixed by #292
Open

Unable to unmarshal BoolVal to Yempty (GNMIEncoding) #291

cho-m opened this issue Jul 7, 2019 · 0 comments · May be fixed by #292

Comments

@cho-m
Copy link
Contributor

cho-m commented Jul 7, 2019

Currently in ytypes/leaf.go, the gNMIToYANGTypeMatches and sanitizeGNMI functions do not support yang.Yempty.

A simple testcase to check this:

$ git diff
diff --git a/ytypes/leaf_test.go b/ytypes/leaf_test.go
index 8d0181a..00ce92d 100644
--- a/ytypes/leaf_test.go
+++ b/ytypes/leaf_test.go
@@ -1657,6 +1657,16 @@ func TestUnmarshalLeafGNMIEncoding(t *testing.T) {
                        },
                        wantVal: &LeafContainerStruct{BoolLeaf: ygot.Bool(true)},
                },
+               {
+                       desc:     "success gNMI BoolVal to Yempty",
+                       inSchema: typeToLeafSchema("empty-leaf", yang.Yempty),
+                       inVal: &gpb.TypedValue{
+                               Value: &gpb.TypedValue_BoolVal{
+                                       BoolVal: true,
+                               },
+                       },
+                       wantVal: &LeafContainerStruct{EmptyLeaf: YANGEmpty(true)},
+               },
                {
                        desc:     "success gNMI StringVal to Ystring",
                        inSchema: typeToLeafSchema("string-leaf", yang.Ystring),

Test result:

--- FAIL: TestUnmarshalLeafGNMIEncoding (0.00s)
    leaf_test.go:1848: success gNMI BoolVal to Yempty: unmarshalLeaf(&{<nil> <nil> empty-leaf    [] Leaf unset <nil> unset map[]  0xc00042efc0 [] <nil> <nil> [] [] [] [] map[] [] map[] map[] <nil>}, &{<nil> [] <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> [] <nil> <nil> 0 <nil> <nil> false [] []}, bool_val:true , GNMIEncoding): got err=failed to unmarshal &{true} into empty, want err=nil
E0706 17:29:38.442149   18766 util_types.go:170] unexpected type bits in yangBuiltinTypeToGoPtrType
FAIL
exit status 1
FAIL	github.com/openconfig/ygot/ytypes	0.063s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant