Skip to content

Commit

Permalink
test(example): 添加 DaemonSet恢复和停止测试
Browse files Browse the repository at this point in the history
- 新增 TestDaemonSetRestore 函数,用于测试 DaemonSet 的恢复操作- 新增 TestDaemonSetStop函数,用于测试 DaemonSet 的停止操作
- 这些测试用例扩展了现有测试集,确保了对 DaemonSet 资源的完整测试覆盖
  • Loading branch information
weibaohui committed Jan 16, 2025
1 parent 9d4a0aa commit 931c825
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions example/stop_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,42 @@ func TestDeployRestore(t *testing.T) {
t.Log(err)
}
}
func TestDaemonSetRestore(t *testing.T) {
var deploy v1.DaemonSet
err := kom.DefaultCluster().Resource(&deploy).
Namespace("default").
Name("nginx-daemonset-test").
Ctl().DaemonSet().Restore()
if err != nil {
t.Log(err)
}
}
func TestDaemonSetStop(t *testing.T) {
yaml := `apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-daemonset-test
namespace: default
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx:alpine
name: nginx
`
kom.DefaultCluster().Applier().Apply(yaml)
var deploy v1.DaemonSet
err := kom.DefaultCluster().Resource(&deploy).
Namespace("default").
Name("nginx-daemonset-test").
Ctl().DaemonSet().Stop()
if err != nil {
t.Log(err)
}
}

0 comments on commit 931c825

Please sign in to comment.