add ut function for util/name.go
Signed-off-by: xin.li <xin.li@daocloud.io>
This commit is contained in:
parent
c817ace443
commit
d89d92fa5b
|
@ -290,6 +290,26 @@ func TestGenerateDerivedServiceName(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGenerateEstimatorDeploymentName(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
clusterName string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "generate estimator deployment name",
|
||||||
|
clusterName: "cluster",
|
||||||
|
expected: "karmada-scheduler-estimator-cluster",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
got := GenerateEstimatorDeploymentName(test.clusterName)
|
||||||
|
if got != test.expected {
|
||||||
|
t.Errorf("Test %s failed: expected %v, but got %v", test.name, test.expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestGenerateEstimatorServiceName(t *testing.T) {
|
func TestGenerateEstimatorServiceName(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -369,3 +389,27 @@ func TestGenerateImpersonationSecretName(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGeneratePolicyName(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
namespace string
|
||||||
|
resourcename string
|
||||||
|
gvk string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "generate policy name",
|
||||||
|
namespace: "ns-foo",
|
||||||
|
resourcename: "foo",
|
||||||
|
gvk: "rand",
|
||||||
|
expected: "foo-b4978784",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
got := GeneratePolicyName(test.namespace, test.resourcename, test.gvk)
|
||||||
|
if got != test.expected {
|
||||||
|
t.Errorf("Test %s failed: expected %v, but got %v", test.name, test.expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue