diff --git a/module/gitlab/test/model/apiget.php b/module/gitlab/test/model/apiget.php new file mode 100644 index 0000000000..e1f3b867f4 --- /dev/null +++ b/module/gitlab/test/model/apiget.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +gen(5); +zdTable('repo')->config('repo')->gen(5); + +$gitlab = new gitlabTest(); + +$hostID = 1; +$host = 'https://gitlabdev.qc.oop.cc/api/v4%s?private_token=glpat-b8Sa1pM9k9ygxMZYPN6w'; +$host2 = 'abc.com'; +$api = '/user'; + +r($gitlab->apiGetTest($host, $api)) && p() && e('success'); //用host url 发送一个请求 +r($gitlab->apiGetTest($hostID, $api)) && p() && e('success'); //用host ID 发送一个请求 +r($gitlab->apiGetTest($host2, $api)) && p() && e('return null'); //用不合规范的host url 发送一个请求 +r($gitlab->apiGetTest(0, $api)) && p() && e('return null'); //用不存在host ID 发送一个请求 diff --git a/module/gitlab/test/model/apipost.php b/module/gitlab/test/model/apipost.php new file mode 100644 index 0000000000..c01537f7d4 --- /dev/null +++ b/module/gitlab/test/model/apipost.php @@ -0,0 +1,59 @@ +#!/usr/bin/env php +gen(5); +zdTable('repo')->config('repo')->gen(5); + +$gitlab = $tester->loadModel('gitlab'); + +$gitlabID = 1; +/* Create user. */ +$user = new stdclass(); +$user->name = 'apiCreatedUser'; +$user->username = 'apiuser17'; +$user->email = 'apiuser17@test.com'; +$user->password = '12345678'; +$gitlab->apiCreateUser($gitlabID, $user); + +/* Get userID. */ +$gitlabUsers = $gitlab->apiGetUsers($gitlabID); +foreach($gitlabUsers as $gitlabUser) +{ + if($gitlabUser->account == 'apiuser17') + { + $userID = $gitlabUser->id; + break; + } +} + +$user = new stdclass(); +$user->name = 'apiUpdatedUser'; + +$gitlabTest = new gitlabTest(); + +$hostID = 1; +$host = 'https://gitlabdev.qc.oop.cc/api/v4%s?private_token=glpat-b8Sa1pM9k9ygxMZYPN6w'; +$host2 = 'abc.com'; +$api = '/user'; +$options = array(CURLOPT_CUSTOMREQUEST => 'PUT'); + +r($gitlabTest->apiPostTest($host, $api, $user, $options)) && p() && e('success'); //用host url 发送一个请求 +r($gitlabTest->apiPostTest($hostID, $api, $user, $options)) && p() && e('success'); //用host ID 发送一个请求 +r($gitlabTest->apiPostTest($host2, $api, $user, $options)) && p() && e('return null'); //用不合规范的host url 发送一个请求 +r($gitlabTest->apiPostTest(0, $api, $user, $options)) && p() && e('return null'); //用不存在host ID 发送一个请求 \ No newline at end of file diff --git a/module/gitlab/test/model/getfilelastcommit.php b/module/gitlab/test/model/getfilelastcommit.php new file mode 100644 index 0000000000..b477d1c057 --- /dev/null +++ b/module/gitlab/test/model/getfilelastcommit.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +gen(5); +zdTable('repo')->config('repo')->gen(5); + +$gitlab = new gitlabTest(); + +$repoID = 1; +$path = 'unitfile'; +$path2 = 'public'; +$path3 = 'getfilelastcommit'; +$branch = 'branch1'; + +r($gitlab->getFileLastCommitTest($repoID, $path)) && p('message,authorName') && e('unitfile,Administrator'); //获取版本库1 unitfile文件最后一次提交信息 +r($gitlab->getFileLastCommitTest($repoID, $path2)) && p('message,authorName') && e('2023-12-21,Administrator'); //获取版本库1 public文件夹最后一次提交信息 +r($gitlab->getFileLastCommitTest($repoID, $path3, $branch)) && p('message,authorName') && e('getFileLastCommit单测,Administrator'); //获取版本库1 public文件夹最后一次提交信息