From 911d0909b6bf0f675ce6788d7f98970808f5cd0a Mon Sep 17 00:00:00 2001 From: xjshen Date: Sat, 24 Sep 2022 18:34:00 +0800 Subject: [PATCH] feat-pkg-cloudproviders-qcloud-tke Signed-off-by: xjshen --- pkg/cloudproviders/qcloud/tke_test.go | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 pkg/cloudproviders/qcloud/tke_test.go diff --git a/pkg/cloudproviders/qcloud/tke_test.go b/pkg/cloudproviders/qcloud/tke_test.go new file mode 100644 index 0000000..9475ed5 --- /dev/null +++ b/pkg/cloudproviders/qcloud/tke_test.go @@ -0,0 +1,53 @@ +package qcloud + +import ( + "math" + "reflect" + "testing" + + "github.com/gocrane/fadvisor/pkg/cloud" +) + +func TestTKEPlatform_PlatformCost(t *testing.T) { + nodes := int32(1) + nodes2 := int32(math.MaxInt32) + tests := []struct { + name string + tp *TKEPlatform + cp cloud.PlatformParameter + want *cloud.Prices + }{ + { + name: "base", + cp: cloud.PlatformParameter{}, + want: &cloud.Prices{ + TotalPrice: defaultClusterPriceModel[0].PriceHourly, + }, + }, + { + name: "clusterRealNodes is less than default unit nodes", + cp: cloud.PlatformParameter{ + Nodes: &nodes, + }, + want: &cloud.Prices{ + TotalPrice: defaultClusterPriceModel[0].PriceHourly, + }, + }, + { + name: "clusterRealNodes is larger than default unit nodes", + cp: cloud.PlatformParameter{ + Nodes: &nodes2, + }, + want: &cloud.Prices{ + TotalPrice: defaultClusterPriceModel[len(defaultClusterPriceModel)-1].PriceHourly, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.tp.PlatformCost(tt.cp); !reflect.DeepEqual(got, tt.want) { + t.Errorf("TKEPlatform.PlatformCost() = %v, want %v", got, tt.want) + } + }) + } +}