2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
18 This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 platform project (RICP).
21 ==================================================================================
31 "routing-manager/pkg/stub"
32 "github.com/go-openapi/swag"
33 "routing-manager/pkg/models"
34 "routing-manager/pkg/rtmgr"
39 RmrPub.GeneratePolicies() method is tested for happy path case
41 func TestFileWriteAll(t *testing.T) {
45 err = file.WriteAll("ut.rt", &stub.ValidRicComponents)
47 /* This test is for empty file */
48 err = file.WriteAll("", &stub.ValidRicComponents)
53 RmrPush.GeneratePolicies() method is tested for happy path case
55 func TestFileReadAll(t *testing.T) {
59 data, err := file.ReadAll("ut.rt")
62 /* Test to read a Directory */
63 data, err = file.ReadAll("/tmp")
71 func TestFileWriteXApps(t *testing.T) {
75 err = file.WriteXApps("ut.rt", stub.ValidXApps)
77 /*Write data to a file that doesn't exist */
78 err = file.WriteXApps("ut.rtx", stub.ValidXApps)
84 GetSdl instance with correct and incorrect arguments
86 func TestFileGetSdl(t *testing.T) {
90 _, err = GetSdl("file")
97 func TestWriteNewE2TInstance(t *testing.T) {
100 file.WriteNewE2TInstance("", &stub.ValidE2TInstance,"")
102 file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance,"meid_arr")
107 WriteAssRANToE2TInstance
109 func TestWriteAssRANToE2TInstance(t *testing.T) {
112 // File is not provided as argument
113 file.WriteAssRANToE2TInstance("",stub.Rane2tmap)
115 file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance,"")
116 file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
121 WriteDisAssRANFromE2TInstance
123 func TestWriteDisAssRANFromE2TInstance(t *testing.T) {
126 // File is not provided as argument
127 file.WriteDisAssRANFromE2TInstance("",stub.Rane2tmap)
130 file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance,"")
131 file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
132 file.WriteDisAssRANFromE2TInstance("ut.rt",stub.Rane2tmaponlyE2t)
133 //RAN list is present
134 file.WriteNewE2TInstance("ut.rt", &stub.ValidE2TInstance,"")
135 file.WriteAssRANToE2TInstance("ut.rt",stub.Rane2tmap)
136 file.WriteDisAssRANFromE2TInstance("ut.rt",stub.Rane2tmap)
141 WriteDeleteE2TInstance E2TInst *models.E2tDeleteData) error
143 func TestWriteDeleteE2TInstance(t *testing.T) {
146 e2deldata := &models.E2tDeleteData{}
147 // File is not provided as argument
148 file.WriteDeleteE2TInstance("",e2deldata)
149 //Delete E2t Instance,associate new rans and dissociate some rans
150 file.WriteNewE2TInstance("ut.rt", &rtmgr.E2TInstance{
151 Name: "E2Tinstance1",
152 Fqdn: "10.10.10.10:100",
153 Ranlist: []string{"1", "2"},
156 file.WriteNewE2TInstance("ut.rt", &rtmgr.E2TInstance{
157 Name: "E2Tinstance2",
158 Fqdn: "11.11.11.11:100",
159 Ranlist: []string{"3", "4"},
162 file.WriteDeleteE2TInstance("ut.rt",&models.E2tDeleteData{
163 E2TAddress: swag.String("10.10.10.10:100"),
164 //RanNamelistTobeDissociated: []string{"1","2"},
165 RanAssocList: models.RanE2tMap{
166 {E2TAddress: swag.String("11.11.11.11:100"),RanNamelist: []string{"5","6"}},
167 {E2TAddress: swag.String("doesntexist"),RanNamelist: []string{}}, },
169 file.WriteNewE2TInstance("ut.rt", &rtmgr.E2TInstance{
170 Name: "E2Tinstance1",
171 Fqdn: "10.10.10.10:100",
172 Ranlist: []string{"1", "2"},
175 file.WriteDeleteE2TInstance("ut.rt",&models.E2tDeleteData{
176 E2TAddress: swag.String("10.10.10.10:100"),
177 RanNamelistTobeDissociated: []string{"1","2"},
178 RanAssocList: models.RanE2tMap{
179 {E2TAddress: swag.String("11.11.11.11:100"),RanNamelist: []string{"5","6"}},
180 {E2TAddress: swag.String("doesntexist"),RanNamelist: []string{}}, },