+ [misc] Add unit tests for instanceModel::deleteBackupCron() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -498,4 +498,19 @@ class instanceTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleteBackupCron method.
|
||||
*
|
||||
* @param object $instance
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteBackupCronTest(object $instance): bool
|
||||
{
|
||||
$result = $this->objectModel->deleteBackupCron($instance);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 instanceModel::deleteBackupCron();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:正常情况 @1
|
||||
- 步骤2:不存在的ID @1
|
||||
- 步骤3:边界值0 @1
|
||||
- 步骤4:负数ID @1
|
||||
- 步骤5:空ID @1
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/instance.unittest.class.php';
|
||||
|
||||
zendata('cron')->loadYaml('cron_deletebackupcron', false, 2)->gen(10);
|
||||
zendata('instance')->loadYaml('instance_deletebackupcron', false, 2)->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
$instanceTest = new instanceTest();
|
||||
|
||||
// 创建测试用的instance对象
|
||||
$instance1 = new stdClass();
|
||||
$instance1->id = 1;
|
||||
|
||||
$instance2 = new stdClass();
|
||||
$instance2->id = 999;
|
||||
|
||||
$instance3 = new stdClass();
|
||||
$instance3->id = 0;
|
||||
|
||||
$instance4 = new stdClass();
|
||||
$instance4->id = -1;
|
||||
|
||||
$instance5 = new stdClass();
|
||||
$instance5->id = '';
|
||||
|
||||
r($instanceTest->deleteBackupCronTest($instance1)) && p() && e(1); // 步骤1:正常情况
|
||||
r($instanceTest->deleteBackupCronTest($instance2)) && p() && e(1); // 步骤2:不存在的ID
|
||||
r($instanceTest->deleteBackupCronTest($instance3)) && p() && e(1); // 步骤3:边界值0
|
||||
r($instanceTest->deleteBackupCronTest($instance4)) && p() && e(1); // 步骤4:负数ID
|
||||
r($instanceTest->deleteBackupCronTest($instance5)) && p() && e(1); // 步骤5:空ID
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
title: 定时任务表测试数据 - deleteBackupCron方法
|
||||
desc: 用于测试删除定时备份任务的数据
|
||||
author: Claude
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 任务ID
|
||||
range: 1-10
|
||||
|
||||
- field: m
|
||||
note: 分钟
|
||||
range: '30'
|
||||
|
||||
- field: h
|
||||
note: 小时
|
||||
range: '1'
|
||||
|
||||
- field: dom
|
||||
note: 月中天数
|
||||
range: '*'
|
||||
|
||||
- field: mon
|
||||
note: 月份
|
||||
range: '*'
|
||||
|
||||
- field: dow
|
||||
note: 周中天数
|
||||
range: '*'
|
||||
|
||||
- field: command
|
||||
note: 定时任务命令
|
||||
range: 'moduleName=instance&methodName=cronBackup&instanceID=1{3}, moduleName=instance&methodName=cronBackup&instanceID=2{2}, moduleName=other&methodName=test&instanceID=3{5}'
|
||||
|
||||
- field: remark
|
||||
note: 备注信息
|
||||
range: '实例备份任务{10}'
|
||||
|
||||
- field: type
|
||||
note: 任务类型
|
||||
range: 'zentao{10}'
|
||||
|
||||
- field: buildin
|
||||
note: 内建任务标识
|
||||
range: 0{10}
|
||||
|
||||
- field: status
|
||||
note: 任务状态
|
||||
range: 'normal{8}, stop{2}'
|
||||
|
||||
- field: lastTime
|
||||
note: 最后执行时间
|
||||
range: '2023-01-01 00:00:00{10}'
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: 实例表测试数据 - deleteBackupCron方法
|
||||
desc: 用于测试删除定时备份任务的实例数据
|
||||
author: Claude
|
||||
version: 1.0
|
||||
|
||||
fields:
|
||||
- field: id
|
||||
note: 实例ID
|
||||
range: 1-5
|
||||
|
||||
- field: name
|
||||
note: 实例名称
|
||||
range: 'test-instance{5}'
|
||||
format: "%s%d"
|
||||
|
||||
- field: space
|
||||
note: 空间ID
|
||||
range: 1{5}
|
||||
|
||||
- field: k8name
|
||||
note: K8S名称
|
||||
range: 'zentao{5}'
|
||||
format: "%s%d"
|
||||
|
||||
- field: domain
|
||||
note: 域名
|
||||
range: 'test{5}'
|
||||
postfix: '.local.com'
|
||||
|
||||
- field: appType
|
||||
note: 应用类型
|
||||
range: 'zentao{3}, jenkins{1}, gitlab{1}'
|
||||
|
||||
- field: appVersion
|
||||
note: 应用版本
|
||||
range: '18.0{5}'
|
||||
|
||||
- field: status
|
||||
note: 实例状态
|
||||
range: 'running{3}, stopped{1}, creating{1}'
|
||||
|
||||
- field: dbName
|
||||
note: 数据库名称
|
||||
range: 'zentao{5}'
|
||||
format: "%s%d"
|
||||
|
||||
- field: dbUser
|
||||
note: 数据库用户
|
||||
range: 'root{5}'
|
||||
|
||||
- field: dbPassword
|
||||
note: 数据库密码
|
||||
range: '123456{5}'
|
||||
|
||||
- field: createdBy
|
||||
note: 创建者
|
||||
range: 'admin{5}'
|
||||
|
||||
- field: createdDate
|
||||
note: 创建时间
|
||||
range: '2023-01-01 10:00:00{5}'
|
||||
|
||||
- field: editedBy
|
||||
note: 编辑者
|
||||
range: 'admin{5}'
|
||||
|
||||
- field: editedDate
|
||||
note: 编辑时间
|
||||
range: '2023-01-02 10:00:00{5}'
|
||||
|
||||
- field: deleted
|
||||
note: 删除标记
|
||||
range: 0{5}
|
||||
Reference in New Issue
Block a user