From df29039cb6694da64177d3368dc2498417d3b468 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Wed, 27 Dec 2023 18:43:11 +0800 Subject: [PATCH] * Add unit test for insstance. --- .../instance/test/model/dblisttooptions.php | 33 +++++++++++++++++++ .../instance/test/model/filtermemoptions.php | 26 +++++++++++++++ 2 files changed, 59 insertions(+) create mode 100755 module/instance/test/model/dblisttooptions.php create mode 100755 module/instance/test/model/filtermemoptions.php diff --git a/module/instance/test/model/dblisttooptions.php b/module/instance/test/model/dblisttooptions.php new file mode 100755 index 0000000000..b18363c412 --- /dev/null +++ b/module/instance/test/model/dblisttooptions.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +dbListToOptions(); +timeout=0 +cid=1 + +- 查看转换后的options数量 @2 +- 查看转换后的options属性mysql @mysql-server +- 查看转换后的options属性sqllite @sqllite-server + +*/ + +global $tester; +$tester->loadModel('instance'); + +$dbList = array(); +$dbList[1] = new stdClass(); +$dbList[1]->name = 'mysql'; +$dbList[1]->alias = 'mysql-server'; + +$dbList[2] = new stdClass(); +$dbList[2]->name = 'sqllite'; +$dbList[2]->alias = 'sqllite-server'; + +$options = $tester->instance->dbListToOptions($dbList); + +r(count($options)) && p() && e('2'); // 查看转换后的options数量 +r($options) && p('mysql') && e('mysql-server'); // 查看转换后的options +r($options) && p('sqllite') && e('sqllite-server'); // 查看转换后的options \ No newline at end of file diff --git a/module/instance/test/model/filtermemoptions.php b/module/instance/test/model/filtermemoptions.php new file mode 100755 index 0000000000..52af8a613e --- /dev/null +++ b/module/instance/test/model/filtermemoptions.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +domainExists(); +timeout=0 +cid=1 + +- 查看过滤后的内存选项是否正确 @6 +- 查看过滤后的内存选项是否正确 @2 + +*/ + +global $tester; +$tester->loadModel('instance'); + +$resources = new stdclass(); +$resources->min = new stdclass(); + +$resources->min->memory = 1048576 * 1024; +r(count($tester->instance->filterMemOptions($resources))) && p('') && e('6'); // 查看过滤后的内存选项是否正确 + +$resources->min->memory = 16777216 * 1024; +r(count($tester->instance->filterMemOptions($resources))) && p('') && e('2'); // 查看过滤后的内存选项是否正确 \ No newline at end of file