blob: 36b6acf5a822cb05cabdef275d477980ba98e147 [file] [log] [blame]
donNewtonAlpha1d2d6812018-09-14 16:00:02 -04001/*
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
17package tosca_test
18
19import (
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040020 "strings"
21 "testing"
22
23 "gerrit.opencord.org/abstract-olt/models/tosca"
24)
25
26var expectedOutput = `tosca_definitions_version: tosca_simple_yaml_1_0
27imports:
28- custom_types/rcordsubscriber.yaml
29description: Pre-provsion a subscriber
30topology_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
45var sub tosca.SubscriberProvision
46
47func TestAddSubscriber_NewSubscriberProvision(t *testing.T) {
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040048 sub = tosca.NewSubscriberProvision("myName", 20, 2, "onuSerialNumber", "/1/1/1/1/1.9", "/1/1/1/1/1.9-CID", "myCilli")
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040049}
50
51func 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 {
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040059 t.Fatal("ToYaml didn't produce the expected yaml")
60 }
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040061
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040062}