Skip to content

Commit

Permalink
tests: TestDiff updated with presence container tests
Browse files Browse the repository at this point in the history
Co-authored-by: Terje Lafton <[email protected]>
  • Loading branch information
JonasKs and TerjeLafton committed Oct 3, 2024
1 parent 688c727 commit bcaa4dc
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion ygot/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,55 @@ func TestDiff(t *testing.T) {
},
}},
},
}}
}, {
desc: "presence container delete presence",
inOrig: &basicStructPresenceWithStruct{StructField: &basicStructThree{}},
inMod: &basicStructPresenceWithStruct{},
inOpts: []DiffOpt{&WithRespectPresenceContainers{}},
want: &gnmipb.Notification{
Delete: []*gnmipb.Path{{
Elem: []*gnmipb.PathElem{{
Name: "struct-value",
}},
}},
},
}, {
desc: "presence container diff update to add presence",
inOrig: &basicStructPresenceWithStruct{},
inMod: &basicStructPresenceWithStruct{StructField: &basicStructThree{}},
inOpts: []DiffOpt{&WithRespectPresenceContainers{}},
want: &gnmipb.Notification{
Update: []*gnmipb.Update{{
Path: &gnmipb.Path{
Elem: []*gnmipb.PathElem{{
Name: "struct-value",
}},
},
Val: nil,
}},
},
}, {
desc: "presencecontainer should explicitly be deleted",
inOrig: &basicStructPresenceWithStruct{StructField: &basicStructThree{StringValue: String("foo")}},
inMod: &basicStructPresenceWithStruct{},
inOpts: []DiffOpt{&WithRespectPresenceContainers{}},
want: &gnmipb.Notification{
Delete: []*gnmipb.Path{
{Elem: []*gnmipb.PathElem{{Name: "struct-value"}}},
{Elem: []*gnmipb.PathElem{{Name: "struct-value"}, {Name: "third-string-value"}}},
{Elem: []*gnmipb.PathElem{{Name: "struct-value"}, {Name: "config"}, {Name: "third-string-value"}}},
}},
}, {
desc: "presencecontainer without diff opt should NOT explicitly be deleted",
inOrig: &basicStructPresenceWithStruct{StructField: &basicStructThree{StringValue: String("foo")}},
inMod: &basicStructPresenceWithStruct{},
want: &gnmipb.Notification{
Delete: []*gnmipb.Path{
{Elem: []*gnmipb.PathElem{{Name: "struct-value"}, {Name: "third-string-value"}}},
{Elem: []*gnmipb.PathElem{{Name: "struct-value"}, {Name: "config"}, {Name: "third-string-value"}}},
}},
},
}

for _, tt := range tests {
testDiffSingleNotif := func(t *testing.T, funcName string, got *gnmipb.Notification, err error) {
Expand Down

0 comments on commit bcaa4dc

Please sign in to comment.