Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cebdc98
commit c7925ad
Showing
4 changed files
with
262 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
azurerm/internal/services/kusto/parse/kusto_cluster_test.go
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,53 @@ | ||
package parse | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKustoClusterId(t *testing.T) { | ||
testData := []struct { | ||
Name string | ||
Input string | ||
Expected *KustoClusterId | ||
}{ | ||
{ | ||
Name: "Empty", | ||
Input: "", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Cluster", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Cluster ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1", | ||
Expected: &KustoClusterId{ | ||
Name: "cluster1", | ||
ResourceGroup: "group1", | ||
}, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q", v.Name) | ||
|
||
actual, err := KustoClusterID(v.Input) | ||
if err != nil { | ||
if v.Expected == nil { | ||
continue | ||
} | ||
|
||
t.Fatalf("Expected a value but got an error: %s", err) | ||
} | ||
|
||
if actual.Name != v.Expected.Name { | ||
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) | ||
} | ||
|
||
if actual.ResourceGroup != v.Expected.ResourceGroup { | ||
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
azurerm/internal/services/kusto/parse/kusto_database_principal_test.go
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,73 @@ | ||
package parse | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKustoDatabasePrincipalId(t *testing.T) { | ||
testData := []struct { | ||
Name string | ||
Input string | ||
Expected *KustoDatabasePrincipalId | ||
}{ | ||
{ | ||
Name: "Empty", | ||
Input: "", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing FQN", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Databases/database1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Role", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1/FQN/aaduser=;", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Database Principal ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1/Role/Viewer/FQN/aaduser=00000000-0000-0000-0000-000000000000;00000000-0000-0000-0000-000000000000", | ||
Expected: &KustoDatabasePrincipalId{ | ||
Name: "aaduser=00000000-0000-0000-0000-000000000000;00000000-0000-0000-0000-000000000000", | ||
Role: "Viewer", | ||
Database: "database1", | ||
Cluster: "cluster1", | ||
ResourceGroup: "group1", | ||
}, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q", v.Name) | ||
|
||
actual, err := KustoDatabasePrincipalID(v.Input) | ||
if err != nil { | ||
if v.Expected == nil { | ||
continue | ||
} | ||
|
||
t.Fatalf("Expected a value but got an error: %s", err) | ||
} | ||
|
||
if actual.Name != v.Expected.Name { | ||
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) | ||
} | ||
|
||
if actual.Role != v.Expected.Role { | ||
t.Fatalf("Expected %q but got %q for Role", v.Expected.Role, actual.Role) | ||
} | ||
|
||
if actual.Database != v.Expected.Database { | ||
t.Fatalf("Expected %q but got %q for Database", v.Expected.Database, actual.Database) | ||
} | ||
|
||
if actual.Cluster != v.Expected.Cluster { | ||
t.Fatalf("Expected %q but got %q for Cluster", v.Expected.Cluster, actual.Cluster) | ||
} | ||
|
||
if actual.ResourceGroup != v.Expected.ResourceGroup { | ||
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
azurerm/internal/services/kusto/parse/kusto_database_test.go
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,63 @@ | ||
package parse | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKustoDatabaseId(t *testing.T) { | ||
testData := []struct { | ||
Name string | ||
Input string | ||
Expected *KustoDatabaseId | ||
}{ | ||
{ | ||
Name: "Empty", | ||
Input: "", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Cluster", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Databases/database1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Database", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Database ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1", | ||
Expected: &KustoDatabaseId{ | ||
Name: "database1", | ||
Cluster: "cluster1", | ||
ResourceGroup: "group1", | ||
}, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q", v.Name) | ||
|
||
actual, err := KustoDatabaseID(v.Input) | ||
if err != nil { | ||
if v.Expected == nil { | ||
continue | ||
} | ||
|
||
t.Fatalf("Expected a value but got an error: %s", err) | ||
} | ||
|
||
if actual.Name != v.Expected.Name { | ||
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) | ||
} | ||
|
||
if actual.Cluster != v.Expected.Cluster { | ||
t.Fatalf("Expected %q but got %q for Cluster", v.Expected.Cluster, actual.Cluster) | ||
} | ||
|
||
if actual.ResourceGroup != v.Expected.ResourceGroup { | ||
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
azurerm/internal/services/kusto/parse/kusto_eventhub_data_connection_test.go
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,73 @@ | ||
package parse | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestKustoEventHubDataConnectionId(t *testing.T) { | ||
testData := []struct { | ||
Name string | ||
Input string | ||
Expected *KustoEventHubDataConnectionId | ||
}{ | ||
{ | ||
Name: "Empty", | ||
Input: "", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Cluster", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Databases/database1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Database", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Missing Data Connection", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1", | ||
Expected: nil, | ||
}, | ||
{ | ||
Name: "Data Connection ID", | ||
Input: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Kusto/Clusters/cluster1/Databases/database1/DataConnections/connection1", | ||
Expected: &KustoEventHubDataConnectionId{ | ||
Name: "connection1", | ||
Database: "database1", | ||
Cluster: "cluster1", | ||
ResourceGroup: "group1", | ||
}, | ||
}, | ||
} | ||
|
||
for _, v := range testData { | ||
t.Logf("[DEBUG] Testing %q", v.Name) | ||
|
||
actual, err := KustoEventHubDataConnectionID(v.Input) | ||
if err != nil { | ||
if v.Expected == nil { | ||
continue | ||
} | ||
|
||
t.Fatalf("Expected a value but got an error: %s", err) | ||
} | ||
|
||
if actual.Name != v.Expected.Name { | ||
t.Fatalf("Expected %q but got %q for Name", v.Expected.Name, actual.Name) | ||
} | ||
|
||
if actual.Database != v.Expected.Database { | ||
t.Fatalf("Expected %q but got %q for Database", v.Expected.Database, actual.Database) | ||
} | ||
|
||
if actual.Cluster != v.Expected.Cluster { | ||
t.Fatalf("Expected %q but got %q for Cluster", v.Expected.Cluster, actual.Cluster) | ||
} | ||
|
||
if actual.ResourceGroup != v.Expected.ResourceGroup { | ||
t.Fatalf("Expected %q but got %q for Resource Group", v.Expected.ResourceGroup, actual.ResourceGroup) | ||
} | ||
} | ||
} |