Skip to content

Commit

Permalink
更新 Go 版 和 Python 版源码
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Aug 8, 2023
1 parent 8775c0d commit f657ad7
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 33 deletions.
2 changes: 2 additions & 0 deletions UnitAuto-Admin/apijson/CodeUtil.js
Expand Up @@ -6036,6 +6036,7 @@ var CodeUtil = {
return valuesIsNotString ? ' ! value必须是String类型!且必须符合 countArray 这种方法名格式!' : (isWarning ? '' : CodeUtil.getComment('被调用方法名', false, ' '));
case 'constructor':
return valuesIsNotString ? ' ! value必须是String类型!且必须符合 getInstance 这种方法名格式!' : (isWarning ? '' : CodeUtil.getComment('获取类实例的方法名,一般用于单例模式类', false, ' '));
case 'args':
case 'methodArgs':
case 'classArgs':
if (value == null || value instanceof Array) {
Expand Down Expand Up @@ -6535,6 +6536,7 @@ var CodeUtil = {
if (CodeUtil.getType4Request(value) == 'string') {
return isWarning ? '' : '获取类实例的方法名,一般用于单例模式类';
}
case 'args':
case 'methodArgs':
case 'classArgs':
if (value == null || value instanceof Array) {
Expand Down
27 changes: 19 additions & 8 deletions UnitAuto-Admin/index.html
Expand Up @@ -315,11 +315,11 @@
{
"static": true,
"methodArgs": [
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
"type": "long",
"value": 1
},
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
"type": "long",
"value": 2
}
Expand Down Expand Up @@ -978,31 +978,42 @@
var vRemember = document.getElementById("vRemember");

var lang = App == null ? null : App.language;
vUrl.value = lang == CodeUtil.LANGUAGE_GO ? 'test.Divide.Divide' : 'unitauto.test.TestUtil.divide' //main.js里访问不到,可能是script引用顺序问题
vUrl.value = lang == CodeUtil.LANGUAGE_GO ? 'test.Divide' : (lang == CodeUtil.LANGUAGE_PYTHON ? 'unitauto.test.testutil.divide' : 'unitauto.test.TestUtil.divide') //main.js里访问不到,可能是script引用顺序问题
vInput.value = (lang == CodeUtil.LANGUAGE_GO ? `{
"methodArgs": [
{ // 可省略来自动判断的 type: bool,float64,string,map[string]any,[]any
{ // 可省略来自动判断的 type: bool,float64,string,map[string]any,[]any
"type": "int",
"value": 1
},
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
"type": "int",
"value": 2
}
]
}` : (lang == CodeUtil.LANGUAGE_PYTHON ? `{
"args": [
{ // 可省略来自动判断的 type: bool,int,float,str,dict,list
"type": "int",
"value": 1
},
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
"type": "int",
"value": 2
}
]
}` : `{
"static": true,
"methodArgs": [
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
{ // 可省略来自动判断的 type: Boolean,Integer,BigDecimal,String,JSONObject,JSONArray
"type": "long",
"value": 1
},
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
{ // 这个对象还可以简化为 "int:2" 这种字符串形式,方便手动调试。在键值对后按 Enter 回车键自动智能生成补全提示
"type": "long",
"value": 2
}
]
}`) + `
}`)) + `
/*
以上 JSON 文本支持 JSON5 格式。清空文本内容可查看规则。
Expand Down
31 changes: 31 additions & 0 deletions UnitAuto-Go/README.md
Expand Up @@ -9,6 +9,8 @@ UnitAuto Go Library for remote dependencies with GitHub repo, etc.
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225636134-a4daf4ec-9304-44d2-b09a-28497c815188.png">
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225636569-b508fa19-3973-4655-bd49-68742c4d09d0.png">

**Demo:** https://github.com/TommyLemon/unitauto-go-demo

#### 1. 在 go.mod 中添加 GitHub 仓库
#### 1. Add the GitHub repository to go.mod
```go
Expand Down Expand Up @@ -42,3 +44,32 @@ https://github.com/TommyLemon/unitauto-go/blob/main/main.go
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225632360-ce953a58-22b1-4b4e-8b3d-0083edebc71a.png">
<img width="1495" alt="image" src="https://user-images.githubusercontent.com/5738175/225635146-f8dab9d1-76c5-421a-b45e-732e4923fd4d.png">

<br />

### 4. 关于作者
### 4. Author
[https://github.com/TommyLemon](https://github.com/TommyLemon)<br />
<img width="1279" alt="image" src="https://user-images.githubusercontent.com/5738175/199979403-ace8b574-cd64-4582-8c19-b51571945214.png">

如果有什么问题或建议可以 [去 APIAuto 提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。<br >
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
<br />
If you have any questions or suggestions, you can [create an issue](https://github.com/TommyLemon/APIAuto/issues). <br >
If you can added a feature or fixed a bug, please [create a pull request](https://github.com/TommyLemon/unitauto-go/pulls), thank you~


### 5. 其它项目
### 5. Link
创作不易、坚持更难,右上角点 ⭐ Star 支持下吧,谢谢 ^_^

[UnitAuto](https://github.com/TommyLemon/UnitAuto) 机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能

[unitauto-go-demo](https://github.com/TommyLemon/unitauto-go-demo) UnitAuto Go Demo,提供用来做单元测试的业务函数

[unitauto-py](https://github.com/TommyLemon/unitauto-py) UnitAuto Python 库,可通过 pip 仓库等远程依赖

[APIJSON](https://github.com/Tencent/APIJSON) 🚀 腾讯零代码、全功能、强安全 ORM 库 🏆 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构

[APIAuto](https://github.com/TommyLemon/APIAuto) 敏捷开发最强大易用的 HTTP 接口工具,机器学习零代码测试、生成代码与静态检查、生成文档与光标悬浮注释,集 文档、测试、Mock、调试、管理 于一体的一站式体验

[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据
11 changes: 11 additions & 0 deletions UnitAuto-Go/unitauto/method_util.go
Expand Up @@ -76,6 +76,7 @@ var KEY_RETURN = "return"
var KEY_TIME_DETAIL = "time:start|duration|end"
var KEY_CLASS_ARGS = "classArgs"
var KEY_METHOD_ARGS = "methodArgs"
var KEY_ARGS = "args"
var KEY_CALLBACK = "callback"
var KEY_GLOBAL = "global"

Expand Down Expand Up @@ -565,6 +566,16 @@ func InvokeMethod(req map[string]any, instance any, listener Listener[any]) erro
var this_ = GetMap(req, KEY_THIS)
var clsArgs = GetArgList(req, KEY_CLASS_ARGS)
var methodArgs = GetArgList(req, KEY_METHOD_ARGS)
var args = GetArgList(req, KEY_ARGS)
if len(args) > 0 {
if methodArgs != nil {
err := errors.New(KEY_ARGS + " 和 " + KEY_METHOD_ARGS + " 不能同时传!")
completeWithError(pkgName, clsName, methodName, startTime, err, listener)
return err
}

methodArgs = args
}

if IsEmpty(cttName, true) && len(clsArgs) > 0 {
err := errors.New("Go 没有构造函数,不允许单独传 " + KEY_CLASS_ARGS + " ,必须配合 " + KEY_CONSTRUCTOR + " 一起用!")
Expand Down
29 changes: 29 additions & 0 deletions UnitAuto-Python/README.md
Expand Up @@ -54,3 +54,32 @@ if you cannot run the command successfully, try python3:
#### 3. Test by following the main repo

https://github.com/TommyLemon/UnitAuto

<br />

### 4. 关于作者
### 4. Author
[https://github.com/TommyLemon](https://github.com/TommyLemon)<br />
<img width="1279" alt="image" src="https://user-images.githubusercontent.com/5738175/199979403-ace8b574-cd64-4582-8c19-b51571945214.png">

如果有什么问题或建议可以 [去 APIAuto 提 issue](https://github.com/TommyLemon/APIAuto/issues),交流技术,分享经验。<br >
如果你解决了某些 bug,或者新增了一些功能,欢迎 [提 PR 贡献代码](https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md),感激不尽。
<br />
If you have any questions or suggestions, you can [create an issue](https://github.com/TommyLemon/APIAuto/issues). <br >
If you can added a feature or fixed a bug, please [create a pull request](https://github.com/TommyLemon/unitauto-py/pulls), thank you~

<br />

### 5. 其它项目
### 5. Link
创作不易、坚持更难,右上角点 ⭐ Star 支持下吧,谢谢 ^_^

[UnitAuto](https://github.com/TommyLemon/UnitAuto) 机器学习零代码单元测试平台,零代码、全方位、自动化 测试 方法/函数 的正确性、可用性和性能

[unitauto-go](https://github.com/TommyLemon/unitauto-go) UnitAuto Go 库,可通过 GitHub 仓库等远程依赖

[APIJSON](https://github.com/Tencent/APIJSON) 🚀 腾讯零代码、全功能、强安全 ORM 库 🏆 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构

[APIAuto](https://github.com/TommyLemon/APIAuto) 敏捷开发最强大易用的 HTTP 接口工具,机器学习零代码测试、生成代码与静态检查、生成文档与光标悬浮注释,集 文档、测试、Mock、调试、管理 于一体的一站式体验

[SQLAuto](https://github.com/TommyLemon/SQLAuto) 智能零代码自动化测试 SQL 语句执行结果的数据库工具,任意增删改查、任意 SQL 模板变量、一键批量生成参数组合、快速构造大量测试数据
1 change: 1 addition & 0 deletions UnitAuto-Python/main.py
Expand Up @@ -6,6 +6,7 @@
def callback():
pass

# methodutil.config.DEFAULT_MODULE_PATH = "unitauto"
# methodutil.listener.callback = callback

test()
Expand Down

0 comments on commit f657ad7

Please sign in to comment.