+ [misc] Add unit tests for cneModel::restore() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -172,4 +172,20 @@ class cneModelTest extends baseTest
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test restore method.
|
||||
*
|
||||
* @param object $instance
|
||||
* @param string $backupName
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function restoreTest(object $instance, string $backupName, string $account = '')
|
||||
{
|
||||
$result = $this->invokeArgs('restore', [$instance, $backupName, $account]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 cneModel::restore();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行cneTest模块的restoreTest方法,参数是$instance1, 'backup-001' 属性code @600
|
||||
- 执行cneTest模块的restoreTest方法,参数是$instance1, '' 属性code @600
|
||||
- 执行cneTest模块的restoreTest方法,参数是$instance1, 'backup-002', 'testuser' 属性code @600
|
||||
- 执行cneTest模块的restoreTest方法,参数是$instance2, 'backup-003' 属性code @600
|
||||
- 执行cneTest模块的restoreTest方法,参数是$instance1, 'backup-004', '' 属性code @600
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/model.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$cneTest = new cneModelTest();
|
||||
|
||||
$instance1 = new stdclass();
|
||||
$instance1->spaceData = new stdclass();
|
||||
$instance1->spaceData->k8space = 'test-namespace';
|
||||
$instance1->k8name = 'test-app';
|
||||
$instance1->channel = '';
|
||||
|
||||
$instance2 = new stdclass();
|
||||
$instance2->spaceData = new stdclass();
|
||||
$instance2->spaceData->k8space = 'prod-namespace';
|
||||
$instance2->k8name = 'prod-app';
|
||||
$instance2->channel = 'stable';
|
||||
|
||||
r($cneTest->restoreTest($instance1, 'backup-001')) && p('code') && e('600');
|
||||
r($cneTest->restoreTest($instance1, '')) && p('code') && e('600');
|
||||
r($cneTest->restoreTest($instance1, 'backup-002', 'testuser')) && p('code') && e('600');
|
||||
r($cneTest->restoreTest($instance2, 'backup-003')) && p('code') && e('600');
|
||||
r($cneTest->restoreTest($instance1, 'backup-004', '')) && p('code') && e('600');
|
||||
Reference in New Issue
Block a user