|
|
@@ -163,3 +163,65 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestCloudCostProperties_hashKey(t *testing.T) {
|
|
|
+
|
|
|
+ tests := map[string]struct {
|
|
|
+ props *CloudCostProperties
|
|
|
+ want string
|
|
|
+ }{
|
|
|
+ "enpty props": {
|
|
|
+ props: &CloudCostProperties{},
|
|
|
+ want: "cbf29ce484222325",
|
|
|
+ },
|
|
|
+ "All props no labels": {
|
|
|
+ props: &CloudCostProperties{
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
+ Labels: map[string]string{},
|
|
|
+ },
|
|
|
+ want: "a19b7dddf0032572",
|
|
|
+ },
|
|
|
+ "All props": {
|
|
|
+ props: &CloudCostProperties{
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
+ Labels: map[string]string{
|
|
|
+ "label1": "value1",
|
|
|
+ "label2": "value2",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ want: "9d54403e40ad4db6",
|
|
|
+ },
|
|
|
+ "All props swap labels": {
|
|
|
+ props: &CloudCostProperties{
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
+ Labels: map[string]string{
|
|
|
+ "label2": "value2",
|
|
|
+ "label1": "value1",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ want: "9d54403e40ad4db6",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for name, tt := range tests {
|
|
|
+ t.Run(name, func(t *testing.T) {
|
|
|
+ if got := tt.props.hashKey(); got != tt.want {
|
|
|
+ t.Errorf("hashKey() = %v, want %v", got, tt.want)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|