-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknownawsaccountslookup_test.go
71 lines (66 loc) · 1.55 KB
/
knownawsaccountslookup_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package knownawsaccountslookup
import (
"log"
"testing"
)
func TestGetVendorNameFromAccountID(t *testing.T) {
subtests := []struct {
name string
accountId string
expectedResult string
}{
{
name: "test1",
accountId: "454464851268",
expectedResult: "Cloudhealth",
},
{
name: "test2",
accountId: "370134896156",
expectedResult: "Fugue",
},
{
name: "test2",
accountId: "944830124550",
expectedResult: "Fugue",
},
}
for _, subtest := range subtests {
t.Run(subtest.name, func(t *testing.T) {
vendors := NewVendorMap()
vendors.PopulateKnownAWSAccounts()
result := vendors.GetVendorNameFromAccountID(subtest.accountId)
if result != subtest.expectedResult {
log.Fatal("Vendor name does not match expected name")
}
})
}
}
func TestGetAccountIdsFromVendorName(t *testing.T) {
subtests := []struct {
name string
vendorName string
expectedResult []string
}{
{
name: "test1",
vendorName: "Cloudhealth",
expectedResult: []string{"454464851268"},
},
{
name: "test2",
vendorName: "Fugue",
expectedResult: []string{"370134896156", "944830124550"},
},
}
for _, subtest := range subtests {
t.Run(subtest.name, func(t *testing.T) {
vendors := NewVendorMap()
vendors.PopulateKnownAWSAccounts()
result := vendors.GetAccountIdsFromVendorName(subtest.vendorName)
if result[0] != subtest.expectedResult[0] {
log.Fatal("AccountID does not match expected AccountID")
}
})
}
}