|
|
@@ -10,34 +10,46 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
}{
|
|
|
"When properties match between both CloudCostProperties": {
|
|
|
baseCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
intCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
expectedCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
@@ -45,34 +57,46 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
},
|
|
|
"When one of the properties differ in the two CloudCostProperties": {
|
|
|
baseCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
intCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service2",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service2",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
expectedCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
@@ -80,47 +104,108 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
},
|
|
|
"When two of the properties differ in the two CloudCostProperties": {
|
|
|
baseCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
intCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID2",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service2",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID2",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service2",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
expectedCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
+ "When all properties differ in the two CloudCostProperties": {
|
|
|
+ baseCCP: &CloudCostProperties{
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
+ Labels: map[string]string{
|
|
|
+ "key1": "value1",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ intCCP: &CloudCostProperties{
|
|
|
+ Provider: "CustomProvider2",
|
|
|
+ ProviderID: "ProviderID2",
|
|
|
+ AccountID: "WorkGroupID2",
|
|
|
+ AccountName: "AccountName2",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID2",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName2",
|
|
|
+ RegionID: "RegionID2",
|
|
|
+ AvailabilityZone: "AvailabilityZone2",
|
|
|
+ Service: "Service2",
|
|
|
+ Category: "Category2",
|
|
|
+ Labels: map[string]string{
|
|
|
+ "key2": "value2",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ expectedCCP: &CloudCostProperties{
|
|
|
+ Provider: "",
|
|
|
+ ProviderID: "",
|
|
|
+ AccountID: "",
|
|
|
+ AccountName: "",
|
|
|
+ InvoiceEntityID: "",
|
|
|
+ InvoiceEntityName: "",
|
|
|
+ RegionID: "",
|
|
|
+ AvailabilityZone: "",
|
|
|
+ Service: "",
|
|
|
+ Category: "",
|
|
|
+ Labels: map[string]string{},
|
|
|
+ },
|
|
|
+ },
|
|
|
"When labels differ": {
|
|
|
baseCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value1",
|
|
|
"key2": "value2",
|
|
|
@@ -128,12 +213,16 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
},
|
|
|
},
|
|
|
intCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key1": "value2",
|
|
|
"key2": "value2",
|
|
|
@@ -141,12 +230,16 @@ func TestCloudCostPropertiesIntersection(t *testing.T) {
|
|
|
},
|
|
|
},
|
|
|
expectedCCP: &CloudCostProperties{
|
|
|
- Provider: "CustomProvider",
|
|
|
- ProviderID: "ProviderID1",
|
|
|
- AccountID: "WorkGroupID1",
|
|
|
- InvoiceEntityID: "InvoiceEntityID1",
|
|
|
- Service: "Service1",
|
|
|
- Category: "Category1",
|
|
|
+ Provider: "CustomProvider",
|
|
|
+ ProviderID: "ProviderID1",
|
|
|
+ AccountID: "WorkGroupID1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "InvoiceEntityID1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "Service1",
|
|
|
+ Category: "Category1",
|
|
|
Labels: map[string]string{
|
|
|
"key2": "value2",
|
|
|
},
|
|
|
@@ -176,45 +269,57 @@ func TestCloudCostProperties_hashKey(t *testing.T) {
|
|
|
},
|
|
|
"All props no labels": {
|
|
|
props: &CloudCostProperties{
|
|
|
- ProviderID: "providerid1",
|
|
|
- Provider: "provider1",
|
|
|
- AccountID: "workgroup1",
|
|
|
- InvoiceEntityID: "billing1",
|
|
|
- Service: "service1",
|
|
|
- Category: "category1",
|
|
|
- Labels: map[string]string{},
|
|
|
- },
|
|
|
- want: "a19b7dddf0032572",
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
+ Labels: map[string]string{},
|
|
|
+ },
|
|
|
+ want: "d07ffd0bd6d5eaf1",
|
|
|
},
|
|
|
"All props": {
|
|
|
props: &CloudCostProperties{
|
|
|
- ProviderID: "providerid1",
|
|
|
- Provider: "provider1",
|
|
|
- AccountID: "workgroup1",
|
|
|
- InvoiceEntityID: "billing1",
|
|
|
- Service: "service1",
|
|
|
- Category: "category1",
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
Labels: map[string]string{
|
|
|
"label1": "value1",
|
|
|
"label2": "value2",
|
|
|
},
|
|
|
},
|
|
|
- want: "9d54403e40ad4db6",
|
|
|
+ want: "318cb6294bf9e2d5",
|
|
|
},
|
|
|
"All props swap labels": {
|
|
|
props: &CloudCostProperties{
|
|
|
- ProviderID: "providerid1",
|
|
|
- Provider: "provider1",
|
|
|
- AccountID: "workgroup1",
|
|
|
- InvoiceEntityID: "billing1",
|
|
|
- Service: "service1",
|
|
|
- Category: "category1",
|
|
|
+ ProviderID: "providerid1",
|
|
|
+ Provider: "provider1",
|
|
|
+ AccountID: "workgroup1",
|
|
|
+ AccountName: "AccountName1",
|
|
|
+ InvoiceEntityID: "billing1",
|
|
|
+ InvoiceEntityName: "InvoiceEntityName1",
|
|
|
+ RegionID: "RegionID1",
|
|
|
+ AvailabilityZone: "AvailabilityZone1",
|
|
|
+ Service: "service1",
|
|
|
+ Category: "category1",
|
|
|
Labels: map[string]string{
|
|
|
"label2": "value2",
|
|
|
"label1": "value1",
|
|
|
},
|
|
|
},
|
|
|
- want: "9d54403e40ad4db6",
|
|
|
+ want: "318cb6294bf9e2d5",
|
|
|
},
|
|
|
}
|
|
|
for name, tt := range tests {
|