-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy patharchitecture_test.go
44 lines (35 loc) · 1.18 KB
/
architecture_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package alzlib
import (
"testing"
)
func TestRootMgs(t *testing.T) {
az := NewAlzLib(nil)
arch := NewArchitecture("test", az)
mg1 := newArchitectureManagementGroup("mg1", "Management Group 1", true, arch)
mg2 := newArchitectureManagementGroup("mg2", "Management Group 2", true, arch)
mg3 := newArchitectureManagementGroup("mg3", "Management Group 3", true, arch)
// mg4 is a lone root management group
mg4 := newArchitectureManagementGroup("mg4", "Management Group 4", true, arch)
// Set mg2 as the parent of mg1
mg1.parent = mg2
mg2.children.Add(mg1)
// Set mg3 as the parent of mg2
mg2.parent = mg3
mg3.children.Add(mg2)
arch.mgs[mg1.id] = mg1
arch.mgs[mg2.id] = mg2
arch.mgs[mg3.id] = mg3
arch.mgs[mg4.id] = mg4
expected := []*ArchitectureManagementGroup{mg3, mg4}
actual := arch.RootMgs()
if len(actual) != len(expected) {
t.Errorf("Expected %d root management groups, but got %d", len(expected), len(actual))
}
for i := range expected {
if expected[i] != actual[i] {
t.Errorf("Expected root management group %s, but got %s", expected[i].id, actual[i].id)
}
}
}