/
kusto_cluster_test.go
53 lines (46 loc) · 1.17 KB
/
kusto_cluster_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
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)
}
}
}