donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 the original author or authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package tosca_test |
| 18 | |
| 19 | import ( |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 20 | "strings" |
| 21 | "testing" |
| 22 | |
| 23 | "gerrit.opencord.org/abstract-olt/models/tosca" |
| 24 | ) |
| 25 | |
| 26 | var expectedOutput = `tosca_definitions_version: tosca_simple_yaml_1_0 |
| 27 | imports: |
| 28 | - custom_types/rcordsubscriber.yaml |
| 29 | description: Pre-provsion a subscriber |
| 30 | topology_template: |
| 31 | node_templates: |
| 32 | myName: |
| 33 | type: tosca.nodes.RCORDSubscriber |
| 34 | properties: |
| 35 | name: myName |
| 36 | status: pre-provisioned |
| 37 | c_tag: 20 |
| 38 | s_tag: 2 |
| 39 | onu_device: onuSerialNumber |
| 40 | nas_port_id: /1/1/1/1/1.9 |
| 41 | circuit_id: /1/1/1/1/1.9-CID |
| 42 | remote_id: myCilli |
| 43 | ` |
| 44 | |
| 45 | var sub tosca.SubscriberProvision |
| 46 | |
| 47 | func TestAddSubscriber_NewSubscriberProvision(t *testing.T) { |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 48 | sub = tosca.NewSubscriberProvision("myName", 20, 2, "onuSerialNumber", "/1/1/1/1/1.9", "/1/1/1/1/1.9-CID", "myCilli") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | func TestAddSubscriber_ToYaml(t *testing.T) { |
| 52 | y, err := sub.ToYaml() |
| 53 | if err != nil { |
| 54 | t.Fatalf("olt.ToYaml() failed with %v\n", err) |
| 55 | } |
| 56 | |
| 57 | x := strings.Compare(y, expectedOutput) |
| 58 | if x != 0 { |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 59 | t.Fatal("ToYaml didn't produce the expected yaml") |
| 60 | } |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 61 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 62 | } |