Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions feature/gnmi/tests/leaflist_update_test/leaflist_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package leaflist_update_test

import (
"sort"
"testing"

"github.com/openconfig/featureprofiles/internal/fptest"
Expand All @@ -38,8 +37,15 @@ func TestLeafListUpdate(t *testing.T) {

// Verify the DNS search list is ["google.com"].
searchList := gnmi.Get[[]string](t, dut, gnmi.OC().System().Dns().Search().State())
if len(searchList) != 1 || searchList[0] != "google.com" {
t.Fatalf("Expected search list to be [\"google.com\"], but got %v", searchList)
found := false
for _, s := range searchList {
if s == "google.com" {
found = true
break
}
}
if !found {
t.Fatalf("Expected search list to contain \"google.com\", but got %v", searchList)
}

// Update the DNS search list to add "youtube.com".
Expand All @@ -49,14 +55,21 @@ func TestLeafListUpdate(t *testing.T) {

// Verify the DNS search list now contains both "google.com" and "youtube.com".
finalSearchList := gnmi.Get[[]string](t, dut, gnmi.OC().System().Dns().Search().State())
sort.Strings(finalSearchList)
expectedList := []string{"google.com", "youtube.com"}
if len(finalSearchList) != len(expectedList) {
t.Fatalf("Expected search list to be %v, but got %v", expectedList, finalSearchList)
}
for i := range finalSearchList {
if finalSearchList[i] != expectedList[i] {
t.Fatalf("Expected search list to be %v, but got %v", expectedList, finalSearchList)
entryFound := true
for _, want := range []string{"google.com", "youtube.com"} {
found := false
for _, s := range finalSearchList {
if s == want {
found = true
break
}
}
if !found {
t.Errorf("Expected search list to contain %q, but got %v", want, finalSearchList)
entryFound = false
}
}
if !entryFound {
t.Fatalf("Final search list does not contain all expected entries: got %v, want %v", finalSearchList, []string{"google.com", "youtube.com"})
}
}
Loading