Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: bcmmbaga <[email protected]>
  • Loading branch information
bcmmbaga committed Jan 7, 2025
1 parent 9731e6c commit 3918a8d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions management/server/types/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func setupTestAccount() *Account {
AccountID: "accountID",
Name: "network2",
},
{
ID: "network3ID",
AccountID: "accountID",
Name: "network3",
},
},
NetworkRouters: []*routerTypes.NetworkRouter{
{
Expand Down Expand Up @@ -201,6 +206,16 @@ func setupTestAccount() *Account {
Metric: 100,
Enabled: true,
},
{
ID: "router6ID",
NetworkID: "network3ID",
AccountID: "accountID",
Peer: "",
PeerGroups: []string{"group6"},
Masquerade: false,
Metric: 100,
Enabled: false,
},
},
NetworkResources: []*resourceTypes.NetworkResource{
{
Expand All @@ -227,6 +242,12 @@ func setupTestAccount() *Account {
NetworkID: "network1ID",
Enabled: true,
},
{
ID: "resource5ID",
AccountID: "accountID",
NetworkID: "network3ID",
Enabled: false,
},
},
Policies: []*Policy{
{
Expand Down Expand Up @@ -291,6 +312,17 @@ func setupTestAccount() *Account {
},
},
},
{
ID: "policy6ID",
AccountID: "accountID",
Enabled: true,
Rules: []*PolicyRule{
{
ID: "rule6ID",
Enabled: true,
},
},
},
},
}
}
Expand All @@ -312,6 +344,8 @@ func Test_GetResourceRoutersMap(t *testing.T) {
require.Equal(t, 2, len(routers["network2ID"]))
require.NotNil(t, routers["network2ID"]["peer2"])
require.NotNil(t, routers["network2ID"]["peer41"])

require.Equal(t, 0, len(routers["network3ID"]))
}

func Test_GetResourcePoliciesMap(t *testing.T) {
Expand All @@ -322,6 +356,7 @@ func Test_GetResourcePoliciesMap(t *testing.T) {
require.Equal(t, 1, len(policies["resource2ID"]))
require.Equal(t, 2, len(policies["resource3ID"]))
require.Equal(t, 1, len(policies["resource4ID"]))
require.Equal(t, 0, len(policies["resource5ID"]))
}

func Test_AddNetworksRoutingPeersAddsMissingPeers(t *testing.T) {
Expand Down

0 comments on commit 3918a8d

Please sign in to comment.