diff --git a/module/ai/test/lib/ai.unittest.class.php b/module/ai/test/lib/ai.unittest.class.php index dbfa0febb5..55c0b0ec73 100644 --- a/module/ai/test/lib/ai.unittest.class.php +++ b/module/ai/test/lib/ai.unittest.class.php @@ -1472,4 +1472,20 @@ class aiTest return $result; } + + /** + * Test checkAssistantDuplicate method. + * + * @param string $assistantName + * @param int $modelId + * @access public + * @return mixed + */ + public function checkAssistantDuplicateTest($assistantName = null, $modelId = null) + { + $result = $this->objectModel->checkAssistantDuplicate($assistantName, $modelId); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/ai/test/model/checkassistantduplicate.php b/module/ai/test/model/checkassistantduplicate.php new file mode 100755 index 0000000000..1d66849bee --- /dev/null +++ b/module/ai/test/model/checkassistantduplicate.php @@ -0,0 +1,45 @@ +#!/usr/bin/env php +id->range('1-5'); +$table->name->range('Assistant1{2},Assistant2,Assistant3,DeletedAssistant'); +$table->modelId->range('1{3},2{2}'); +$table->desc->range('Test assistant description'); +$table->systemMessage->range('You are a helpful assistant'); +$table->greetings->range('Hello! How can I help you today?'); +$table->icon->range('coding-1'); +$table->enabled->range('1'); +$table->createdDate->range('`2024-01-01 10:00:00`'); +$table->publishedDate->range('`2024-01-01 10:00:00`'); +$table->deleted->range('0{4},1'); +$table->gen(5); + +su('admin'); + +$aiTest = new aiTest(); + +r($aiTest->checkAssistantDuplicateTest('Assistant1', 1)) && p('name,modelId') && e('Assistant1,1'); +r($aiTest->checkAssistantDuplicateTest('NonExistentAssistant', 1)) && p() && e('0'); +r($aiTest->checkAssistantDuplicateTest('Assistant1', 99)) && p() && e('0'); +r($aiTest->checkAssistantDuplicateTest('', 1)) && p() && e('0'); +r($aiTest->checkAssistantDuplicateTest('DeletedAssistant', 1)) && p() && e('0'); \ No newline at end of file diff --git a/module/ai/test/model/yaml/ai_assistant_checkassistantduplicate.yaml b/module/ai/test/model/yaml/ai_assistant_checkassistantduplicate.yaml new file mode 100644 index 0000000000..dccdc23356 --- /dev/null +++ b/module/ai/test/model/yaml/ai_assistant_checkassistantduplicate.yaml @@ -0,0 +1,38 @@ +--- +title: AI助手重复检查测试数据 +desc: 用于测试checkAssistantDuplicate方法的测试数据 + +fields: +- field: id + note: 助手ID + range: 1-5 +- field: name + note: 助手名称 + range: Assistant1{2},Assistant2,Assistant3,DeletedAssistant +- field: modelId + note: 模型ID + range: 1{3},2{2} +- field: desc + note: 助手描述 + range: Test assistant description{5} +- field: systemMessage + note: 系统消息 + range: You are a helpful assistant{5} +- field: greetings + note: 问候语 + range: Hello! How can I help you today?{5} +- field: icon + note: 图标 + range: coding-1{5} +- field: enabled + note: 是否启用 + range: '1'{5} +- field: createdDate + note: 创建时间 + range: '2024-01-01 10:00:00'{5} +- field: publishedDate + note: 发布时间 + range: '2024-01-01 10:00:00'{5} +- field: deleted + note: 是否删除 + range: '0'{4},'1' \ No newline at end of file