blob: 89612138ceec97da5165be4ab2ed1583f1926cf4 [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 (
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040019 "strings"
20 "testing"
21
22 "gerrit.opencord.org/abstract-olt/models/tosca"
23)
24
25var output = `tosca_definitions_version: tosca_simple_yaml_1_0
26imports:
27- custom_types/oltdevice.yaml
28- custom_types/onudevice.yaml
29- custom_types/ponport.yaml
30- custom_types/voltservice.yaml
31description: Create a simulated OLT Device in VOLTHA
32topology_template:
33 node_templates:
34 service#volt:
35 type: tosca.nodes.VOLTService
36 properties:
37 name: volt
38 must-exist: true
39 olt_device:
40 type: tosca.nodes.OLTDevice
41 properties:
42 name: myName
43 device_type: openolt
44 host: 192.168.1.1
45 port: 9191
46 outer_tpid: "0x8100"
47 uplink: "65536"
48 nas_id: my_clli
donNewtonAlphae7ab5b92018-09-27 15:09:14 -040049 switch_datapath_id: of:0000000000000001
50 switch_port: "1"
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040051 requirements:
52 - volt_service:
53 node: service#volt
54 relationship: tosca.relationships.BelongsToOne
55`
56
57var olt tosca.OltProvsion
58
59func TestAddOlt_NewOltProvsion(t *testing.T) {
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040060 olt = tosca.NewOltProvision("my_clli", "myName", "openolt", "192.168.1.1", 9191)
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040061}
62
63func TestAddOlt_ToYaml(t *testing.T) {
64 y, err := olt.ToYaml()
65 if err != nil {
66 t.Fatalf("olt.ToYaml() failed with %v\n", err)
67 }
68 x := strings.Compare(y, output)
69 if x != 0 {
70 t.Fatal("ToYaml didn't produce the expected yaml")
71 }
donNewtonAlpha1d2d6812018-09-14 16:00:02 -040072}