blob: 0d4834082d400034ff974005c3405886189f53a2 [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 (
20 "fmt"
21 "strings"
22 "testing"
23
24 "gerrit.opencord.org/abstract-olt/models/tosca"
25)
26
27var expectedOutput = `tosca_definitions_version: tosca_simple_yaml_1_0
28imports:
29- custom_types/rcordsubscriber.yaml
30description: Pre-provsion a subscriber
31topology_template:
32 node_templates:
33 myName:
34 type: tosca.nodes.RCORDSubscriber
35 properties:
36 name: myName
37 status: pre-provisioned
38 c_tag: 20
39 s_tag: 2
40 onu_device: onuSerialNumber
41 nas_port_id: /1/1/1/1/1.9
42 circuit_id: /1/1/1/1/1.9-CID
43 remote_id: myCilli
44`
45
46var sub tosca.SubscriberProvision
47
48func TestAddSubscriber_NewSubscriberProvision(t *testing.T) {
49 fmt.Println("Int TestAddSubscriber_NewSubscriberProvision")
50 sub = tosca.NewSubscriberProvision("myName", 20, 2, "onuSerialNumber", "/1/1/1/1/1.9", "/1/1/1/1/1.9-CID", "myCilli")
51 fmt.Printf("%v\n\n", sub)
52}
53
54func TestAddSubscriber_ToYaml(t *testing.T) {
55 y, err := sub.ToYaml()
56 if err != nil {
57 t.Fatalf("olt.ToYaml() failed with %v\n", err)
58 }
59
60 x := strings.Compare(y, expectedOutput)
61 if x != 0 {
62 fmt.Println("******")
63 fmt.Println(expectedOutput)
64 fmt.Println("******")
65 fmt.Println(y)
66 fmt.Println("******")
67 t.Fatal("ToYaml didn't produce the expected yaml")
68 }
69 fmt.Printf("Compare is %d\n", x)
70
71 fmt.Printf(y)
72 fmt.Println("******")
73 fmt.Print(output)
74 fmt.Println("******")
75}