blob: 61739fb4f5c8952828dd019d3ffa2710382d0f7f [file] [log] [blame]
gioefa0ed42024-06-13 12:31:43 +04001package installer
2
3import (
4 "testing"
5)
6
7func TestFindPortFields(t *testing.T) {
8 scm := structSchema{
9 "a",
10 []Field{
gio36b23b32024-08-25 12:20:54 +040011 Field{"x", basicSchema{"x", KindString, false, nil}},
12 Field{"y", basicSchema{"y", KindInt, false, nil}},
13 Field{"z", basicSchema{"z", KindPort, false, nil}},
gioefa0ed42024-06-13 12:31:43 +040014 Field{
15 "w",
16 structSchema{
17 "w",
18 []Field{
gio36b23b32024-08-25 12:20:54 +040019 Field{"x", basicSchema{"x", KindString, false, nil}},
20 Field{"y", basicSchema{"y", KindInt, false, nil}},
21 Field{"z", basicSchema{"z", KindPort, false, nil}},
gioefa0ed42024-06-13 12:31:43 +040022 },
23 false,
24 },
25 },
26 },
27 false,
28 }
29 p := findPortFields(scm)
30 if len(p) != 2 {
31 t.Fatalf("expected two port fields, %v", p)
32 }
33 if p[0] != "z" || p[1] != "w.z" {
34 t.Fatalf("expected 'z' and 'w.z' port fields, %v", p)
35 }
36}