blob: 1b2f6676dfa4e6d23dda3cf7fdf83fd976f29cf2 [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*/
16package tosca_test
17
18import (
19 "fmt"
20 "strings"
21 "testing"
22
23 "gerrit.opencord.org/abstract-olt/models/tosca"
24)
25
26var output = `tosca_definitions_version: tosca_simple_yaml_1_0
27imports:
28- custom_types/oltdevice.yaml
29- custom_types/onudevice.yaml
30- custom_types/ponport.yaml
31- custom_types/voltservice.yaml
32description: Create a simulated OLT Device in VOLTHA
33topology_template:
34 node_templates:
35 service#volt:
36 type: tosca.nodes.VOLTService
37 properties:
38 name: volt
39 must-exist: true
40 olt_device:
41 type: tosca.nodes.OLTDevice
42 properties:
43 name: myName
44 device_type: openolt
45 host: 192.168.1.1
46 port: 9191
47 outer_tpid: "0x8100"
48 uplink: "65536"
49 nas_id: my_clli
50 requirements:
51 - volt_service:
52 node: service#volt
53 relationship: tosca.relationships.BelongsToOne
54`
55
56var olt tosca.OltProvsion
57
58func TestAddOlt_NewOltProvsion(t *testing.T) {
59 fmt.Println("In TestAddOlt_NewOltProvsion")
60 olt = tosca.NewOltProvision("my_clli", "myName", "openolt", "192.168.1.1", 9191)
61 fmt.Printf("%v\n\n", olt)
62}
63
64func TestAddOlt_ToYaml(t *testing.T) {
65 y, err := olt.ToYaml()
66 if err != nil {
67 t.Fatalf("olt.ToYaml() failed with %v\n", err)
68 }
69 x := strings.Compare(y, output)
70 if x != 0 {
71 t.Fatal("ToYaml didn't produce the expected yaml")
72 }
73 fmt.Printf("Compare is %d\n", x)
74
75 fmt.Printf(y)
76 fmt.Println("******")
77 fmt.Print(output)
78 fmt.Println("******")
79}