{"id":15320007,"url":"https://github.com/chenhg5/guardian","last_synced_at":"2025-04-14T23:33:28.816Z","repository":{"id":57607489,"uuid":"150372114","full_name":"chenhg5/guardian","owner":"chenhg5","description":"golang testing framework","archived":false,"fork":false,"pushed_at":"2019-03-26T10:14:43.000Z","size":5335,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T11:39:05.198Z","etag":null,"topics":["framework","golang","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenhg5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-26T05:16:42.000Z","updated_at":"2020-08-03T09:05:01.000Z","dependencies_parsed_at":"2022-08-30T04:41:35.439Z","dependency_job_id":null,"html_url":"https://github.com/chenhg5/guardian","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhg5%2Fguardian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhg5%2Fguardian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhg5%2Fguardian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenhg5%2Fguardian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenhg5","download_url":"https://codeload.github.com/chenhg5/guardian/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248979768,"owners_count":21193033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","golang","testing"],"created_at":"2024-10-01T09:06:53.334Z","updated_at":"2025-04-14T23:33:28.768Z","avatar_url":"https://github.com/chenhg5.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guardian\n\napi测试框架，表格测试，编写json文件，即可测试api的响应以及对应数据库的正确性，以及测试并发的数据准确性。\n\n## 下载安装\n\n在 https://github.com/chenhg5/guardian/releases 下载对应版本，或者执行：\n\n```bash\ngo get -u -v github.com/chenhg5/guardian\n```\n\n## 使用\n\n```\nguardian --tests=./example/tests/entrance.json\n\nSUIT:  users\n=================================================\n获取用户                                    Ok\n-------------------------------------------------\n响应比对                                    ✓️\n数据比对                                    ✓️\n=================================================\n修改用户                                    Ok\n-------------------------------------------------\n响应比对                                    ✓️\n数据比对                                    ✓️\n=================================================\n\nOk\n\nSUIT:  orders\n=================================================\n获取订单                                    Ok\n-------------------------------------------------\n响应比对                                    ✓️\n数据比对                                    ✓️\n=================================================\n创建订单                                    Ok\n-------------------------------------------------\n响应比对                                    ✓️\n数据比对                                    ✓️\n=================================================\n\nOk\n\n```\n\n```entrance.json```为入口文件，例子详见 example/tests/entrance.json\n\n## json格式\n\n### 入口文件\n\n| 选项名 | 子选项名 | 描述 | 格式 | 是否必须 | 例子 |\n| ------ | ------ | ------ | ------ | ------ | ------ |\n| database | port | 端口 |  字符串 | 是 | 3306 |\n|  | user | 用户 | 字符串 | 是 | root |\n|  | password | 密码 | 字符串 | 是 | root |\n|  | charset | 字符集 | 字符串 | 是 | utf8 |\n|  | host | 地址 | 字符串 | 是 | 127.0.0.1 |\n|  | database | 数据库名 | 字符串 | 是 | guardian |\n| tables | 无 | 案例集 | 对象 | 是 | { \u003cbr\u003e\"users\": { \"list\": [\"users/get.json\", \"users/post.json\" ], \"pre-execution\": [], \"after-execution\": []}\u003cbr\u003e}\n| vars | 无 | 全局变量，在案例文件中用\u003cbr\u003e{{host}}这种格式表示 | 对象 | 否 | { \"host\": \"http://127.0.0.1:1235\" } |\n| debug | 无 | 设置为true则会\u003cbr\u003e打印所有返回结果\u003cbr\u003e与数据库查询结果 |  布尔 | 否 | false |\n                            \n### 测试案例\n\n| 选项名 | 子选项名 | 描述 | 格式 | 是否必须 | 例子 |\n| ------ | ------ | ------ | ------ | ------ | ------ |\n| info | title | 标题 | 字符串 | 是 | 这是一个标题 |\n|  | description | 描述 | 字符串 | 是 | 这是一个描述 |\n| concurrent | 无 | 并发数 | 整数 | 否 | 1 |\n| request | url | url | 字符串 | 是 | {{host}}/user |\n|  | method | 方法: json, get, post, delete, options, formget, formpost | 字符串 | 是 | get |\n|  | params | 参数 | 对象或数组 | 否 | {\"id\": 1} |\n|  | header | 头部 | 对象  | 否 | {\"token\": \"1231313\"} |\n| response | body | 返回body数据，对象中可以有\u003cbr\u003e通配符，如\"*\"，表示不匹配 | 字符串或对象 | 是 | 123 |\n|  | header | 头部 | 对象  | 否 | {\"token\": \"1231313\"} |\n|  | statusCode | 状态码 | 整数  | 否 | 200 |\n| data | 无 | 验证数据 | 数组 | 否 | [\u003cbr\u003e  {\u003cbr\u003e   \"sql\": \"select name from user where id = 1\",\u003cbr\u003e    \"result\": [{\"name\": \"jack\"}]\u003cbr\u003e    }\u003cbr\u003e] |\n| after | 无 | 全局变量更新 | 对象 | 否 | { \"host\": \"http://127.0.0.1:1235\" } |\n\n## 项目信息\n\n### 流程\n\n- 输入表格集\n    - 输入参数：\n        - url\n        - method\n        - param\n    \n    - 对比响应：\n        - json\n        - 字符串\n    \n    - 核对数据：\n        - mysql\n        - redis\n    \n    - 记录结果        \n- 输出结果\n    \n### 组成部分\n\n- 请求函数\n    - json post\n    - get\n    - 表单 post\n    - 表单 get\n    \n- 响应对比\n    - 字符串对比\n        - 完全一致\n        - 包含\n    - json对比\n        - 完全一致\n        - 结构一致\n        - 结构一致且部分数据一致\n\n- 数据获取\n    - sql连接\n        - mysql\n    - redis\n\n- 全局变量管理\n    - 定义全局变量\n    - 读取变量  \n\n- io部分\n    - 输出到终端/文件\n    - 读取文件\n\n### 表格读取\n\n入口文件为json格式\n\n- 数据库\n- redis\n- 测试表格集\n\n表格为json格式\n\n- 测试信息\n    - 标题\n    - 描述\n\n- 请求\n    - url\n    - method\n    - param\n    - header   \n    \n- 响应\n    - header\n    - body\n    - 对比方式\n\n- 数据\n    - sql\n    - 期待结果\n    - 对比方式   \n    \n## TODO\n\n- 增加web ui显示测试案例及运行情况\n- 完善例子\n- 增加网站说明\n- 增加英文版说明                                ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenhg5%2Fguardian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenhg5%2Fguardian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenhg5%2Fguardian/lists"}