X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fpublishservice%2Fpublishservice_test.go;h=3f1a71f64c1e9899c7deb639773e1c07a2928cba;hb=8fa464fbe92fe7fa2107915accfe93cb932fb021;hp=e63243fd87c11a162ed5713bc66a0dcab9d6425a;hpb=b70522851289af2045d3d0c950b053b5673705cd;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/publishservice/publishservice_test.go b/capifcore/internal/publishservice/publishservice_test.go index e63243f..3f1a71f 100644 --- a/capifcore/internal/publishservice/publishservice_test.go +++ b/capifcore/internal/publishservice/publishservice_test.go @@ -68,7 +68,6 @@ func TestUnregisteredService(t *testing.T) { assert.Equal(t, http.StatusNotFound, *resultError.Status) } - func TestPublishUnpublishService(t *testing.T) { apfId := "apfId" @@ -262,17 +261,13 @@ func TestGetPublishedServices(t *testing.T) { func TestGetAllowedServices(t *testing.T) { serviceUnderTest := NewPublishService(nil, nil, nil) - aefProfiles1 := []publishapi.AefProfile{ - } + aefProfiles1 := []publishapi.AefProfile{} apiId1 := "apiId1" - aefProfiles2 := []publishapi.AefProfile{ - } + aefProfiles2 := []publishapi.AefProfile{} apiId2 := "apiId2" - aefProfiles3 := []publishapi.AefProfile{ - } + aefProfiles3 := []publishapi.AefProfile{} apiId3 := "apiId3" - aefProfiles4 := []publishapi.AefProfile{ - } + aefProfiles4 := []publishapi.AefProfile{} apiId4 := "apiId4" serviceUnderTest.publishedServices["publisher1"] = []publishapi.ServiceAPIDescription{ @@ -315,6 +310,22 @@ func TestGetAllowedServices(t *testing.T) { result := serviceUnderTest.GetAllowedPublishedServices(allowedApiList) assert.Len(t, result, 2) + + result = serviceUnderTest.GetAllowedPublishedServices(nil) + assert.Len(t, result, 0) + + result = serviceUnderTest.GetAllowedPublishedServices([]publishapi.ServiceAPIDescription{}) + assert.Len(t, result, 0) + + // Create a list with no ApiIds + badApiList := []publishapi.ServiceAPIDescription{ + { + }, + { + }, + } + result = serviceUnderTest.GetAllowedPublishedServices(badApiList) + assert.Len(t, result, 0) } func TestUpdateDescription(t *testing.T) {