From f7fbf652ee9935ccc327d80efc84274f17a106db Mon Sep 17 00:00:00 2001 From: "Arrobo, Gabriel" Date: Fri, 5 Jun 2026 21:47:15 -0700 Subject: [PATCH 1/2] Use accessors (new, get, set) instead of direct field access Signed-off-by: Arrobo, Gabriel --- nrfcache/nrfcache.go | 6 +++--- nrfcache/nrfcache_test.go | 17 +++++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/nrfcache/nrfcache.go b/nrfcache/nrfcache.go index 536f8266..c7c731b5 100644 --- a/nrfcache/nrfcache.go +++ b/nrfcache/nrfcache.go @@ -80,7 +80,7 @@ func (npq NfProfilePriorityQ) at(index int) *NfProfileItem { // push - adds an entry to the priority queue. Invokes heap api to // push the entry to the correct location in the queue -func (npq *NfProfilePriorityQ) push(item interface{}) { +func (npq *NfProfilePriorityQ) push(item any) { heap.Push(npq, item) } @@ -98,7 +98,7 @@ func (npq *NfProfilePriorityQ) remove(item *NfProfileItem) { } // Push - implemented for heap interface. appends an element to the priority queue -func (npq *NfProfilePriorityQ) Push(item interface{}) { +func (npq *NfProfilePriorityQ) Push(item any) { n := len(*npq) entry := item.(*NfProfileItem) entry.index = n @@ -106,7 +106,7 @@ func (npq *NfProfilePriorityQ) Push(item interface{}) { } // Pop - implemented for heap interface. Removes the entry with expiry time -func (npq *NfProfilePriorityQ) Pop() interface{} { +func (npq *NfProfilePriorityQ) Pop() any { old := *npq n := len(old) item := old[n-1] diff --git a/nrfcache/nrfcache_test.go b/nrfcache/nrfcache_test.go index 23be4d1e..1e82a957 100644 --- a/nrfcache/nrfcache_test.go +++ b/nrfcache/nrfcache_test.go @@ -1111,15 +1111,12 @@ func TestCacheKeyBehavior(t *testing.T) { // Check if the MatchAmfProfile function is working correctly func TestAmfProfileMatching(t *testing.T) { // Create a test AMF profile - amfProfile := models.NFProfileDiscovery{ - NfInstanceId: "9f7d5a3f-88ab-4525-b31e-334da7faedab", - NfType: models.NFTYPE_AMF, - PlmnList: []models.PlmnId{{Mcc: "208", Mnc: "93"}}, - AmfInfo: &models.AmfInfo{ - AmfRegionId: "ca", - AmfSetId: "3f8", - }, - } + amfProfile := models.NewNFProfileDiscovery("9f7d5a3f-88ab-4525-b31e-334da7faedab", models.NFTYPE_AMF, models.NFSTATUS_REGISTERED) + amfProfile.SetPlmnList([]models.PlmnId{{Mcc: "208", Mnc: "93"}}) + amfProfile.SetAmfInfo(models.AmfInfo{ + AmfRegionId: "ca", + AmfSetId: "3f8", + }) testCases := []struct { param Nnrf_NFDiscovery.ApiSearchNFInstancesRequest @@ -1140,7 +1137,7 @@ func TestAmfProfileMatching(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - match, err := MatchAmfProfile(&amfProfile, tc.param) + match, err := MatchAmfProfile(amfProfile, tc.param) if err != nil { t.Fatalf("MatchAmfProfile failed: %v", err) } From 3ed23960ba05ccdd1a8a8d71624c8d2e3000f5b9 Mon Sep 17 00:00:00 2001 From: "Arrobo, Gabriel" Date: Fri, 5 Jun 2026 21:50:48 -0700 Subject: [PATCH 2/2] Address Copilot's comment Signed-off-by: Arrobo, Gabriel --- nrfcache/nrfcache.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nrfcache/nrfcache.go b/nrfcache/nrfcache.go index c7c731b5..23adb015 100644 --- a/nrfcache/nrfcache.go +++ b/nrfcache/nrfcache.go @@ -80,7 +80,7 @@ func (npq NfProfilePriorityQ) at(index int) *NfProfileItem { // push - adds an entry to the priority queue. Invokes heap api to // push the entry to the correct location in the queue -func (npq *NfProfilePriorityQ) push(item any) { +func (npq *NfProfilePriorityQ) push(item *NfProfileItem) { heap.Push(npq, item) }