Skip to content

Commit 952f69f

Browse files
committed
Refactor GetApplicationEnvironments tests to use labels for namespace and application
1 parent f8f1bd6 commit 952f69f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/resource/control_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ func TestGetApplicationEnvironments(t *testing.T) {
2828
config.ControlPlaneUrl = mockServer.URL
2929
defer func() { config.ControlPlaneUrl = originalURL }()
3030

31+
// 设置测试数据
32+
labels := map[string]string{
33+
config.ServiceSpaceLabel: "test-namespace",
34+
config.ApplicationLabel: "test-application",
35+
}
36+
3137
// 调用被测试函数
32-
data, err := GetApplicationEnvironments("test-namespace", "test-application")
38+
data, err := GetApplicationEnvironments(labels)
3339

3440
// 验证结果
3541
assert.NoError(t, err)
@@ -42,8 +48,14 @@ func TestGetApplicationEnvironments(t *testing.T) {
4248
func TestGetApplicationEnvironments2(t *testing.T) {
4349
config.ControlPlaneUrl = "http://localhost:8000/v1"
4450

51+
// 设置测试数据
52+
labels := map[string]string{
53+
config.ServiceSpaceLabel: "test-namespace",
54+
config.ApplicationLabel: "test-application",
55+
}
56+
4557
// 调用被测试函数
46-
data, err := GetApplicationEnvironments("default1", "showcase-agent-a1")
58+
data, err := GetApplicationEnvironments(labels)
4759

4860
// 验证结果
4961
assert.NoError(t, err)

0 commit comments

Comments
 (0)