-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: establish azure resource relationship to resource group &
subscription
- Loading branch information
1 parent
b13a4df
commit 48ae87e
Showing
2 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package azure | ||
|
||
import "testing" | ||
|
||
func TestExtractResourceGroup(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expectedOutput string | ||
}{ | ||
// Valid input cases | ||
{"/subscriptions/0cd017bb-aa54-5121-b21f-ecf8daee0624/resourcegroups/mc_demo_demo_francecentral", "mc_demo_demo_francecentral"}, | ||
{"/subscriptions/0cd017bb-aa54-5121-b21f-ecf8daee0624/resourcegroups/crossplane", "crossplane"}, | ||
{"/subscriptions/0cd017bb-aa54-5121-b21f-ecf8daee0624/resourcegroups/crossplane/providers/microsoft.containerservice/managedclusters/workload-prod-eu-01", "crossplane"}, | ||
{"/subscriptions/0cd017bb-aa54-5121-b21f-ecf8daee0624/resourcegroups/internal-prod/providers/microsoft.storage/storageaccounts/flanksourcebackups", "internal-prod"}, | ||
{"/subscriptions/0cd017bb-aa54-5121-b21f-ecf8daee0624/resourcegroups/mc_crossplane_crossplane-master_northeurope/providers/microsoft.network/loadbalancers/kubernetes", "mc_crossplane_crossplane-master_northeurope"}, | ||
|
||
// Invalid input cases | ||
{"", ""}, | ||
{"/subscriptions/123", ""}, | ||
{"/subscriptions/456/notresourcegroup/test", ""}, | ||
} | ||
|
||
for _, test := range tests { | ||
result := extractResourceGroup(test.input) | ||
if result != test.expectedOutput { | ||
t.Errorf("Input: %s, Expected: %s, Got: %s", test.input, test.expectedOutput, result) | ||
} | ||
} | ||
} |