{"id":36440684,"url":"https://github.com/the-sumeet/goresttest","last_synced_at":"2026-01-11T21:56:46.746Z","repository":{"id":285913819,"uuid":"959745496","full_name":"the-sumeet/goresttest","owner":"the-sumeet","description":"REST API testing framework","archived":false,"fork":false,"pushed_at":"2025-08-07T20:18:14.000Z","size":6746,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-07T22:03:51.600Z","etag":null,"topics":["api-client","rest-api","rest-test","test-automation","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/the-sumeet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-04-03T09:31:59.000Z","updated_at":"2025-08-07T20:17:33.000Z","dependencies_parsed_at":"2025-04-03T10:43:27.917Z","dependency_job_id":null,"html_url":"https://github.com/the-sumeet/goresttest","commit_stats":null,"previous_names":["the-sumeet/goresttest"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/the-sumeet/goresttest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-sumeet%2Fgoresttest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-sumeet%2Fgoresttest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-sumeet%2Fgoresttest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-sumeet%2Fgoresttest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-sumeet","download_url":"https://codeload.github.com/the-sumeet/goresttest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-sumeet%2Fgoresttest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28324553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api-client","rest-api","rest-test","test-automation","testing"],"created_at":"2026-01-11T21:56:46.105Z","updated_at":"2026-01-11T21:56:46.738Z","avatar_url":"https://github.com/the-sumeet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoRestTest\n\nGoRestTest is a powerful REST API testing framework for Go that can be used both as a library and as a CLI tool. It's inspired by pyresttest and provides comprehensive features for testing REST APIs including assertions, variable extraction, test dependencies, and parallel execution.\n\n## Features\n\n- **Dual Usage**: Can be used both as a Go library and as a CLI tool\n- **Comprehensive Assertions**: Status codes, JSON paths, HTML selectors, headers, response time, regex matching, and body content\n- **Variable Extraction**: Extract data from responses for use in subsequent tests\n- **Test Dependencies**: Define test execution order with depends_on\n- **Parallel Execution**: Run independent tests in parallel for faster execution\n- **Multiple Report Formats**: Console, JSON, and HTML reports\n- **Variable Interpolation**: Use variables in test definitions\n- **Body File Support**: Load request bodies from external files\n\n## Installation\n\n### As a CLI Tool\n\n```bash\ngo install github.com/the-sumeet/goresttest/cmd/goresttest@latest\n```\n\n### As a Library\n\n```bash\ngo get github.com/the-sumeet/goresttest@latest\n```\n\n## Usage\n\n### CLI Tool\n\n```bash\n# Basic usage\ngoresttest -config tests.yaml\n\n# Parallel execution\ngoresttest -config tests.yaml -parallel -workers 5\n\n# Generate HTML report\ngoresttest -config tests.yaml -output html -file report.html\n\n# Generate JSON report\ngoresttest -config tests.yaml -output json -file report.json\n\n# Verbose output\ngoresttest -config tests.yaml -verbose\n```\n\n### Library Usage\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"log\"\n    \n    \"github.com/the-sumeet/goresttest\"\n)\n\nfunc main() {\n    // Parse test suite from file\n    suite, err := goresttest.ParseTestSuite(\"tests.yaml\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    // Create test runner\n    runner := goresttest.NewTestRunner(suite.BaseURL)\n    \n    // Execute test suite\n    results, err := runner.RunTestSuite(suite)\n    if err != nil {\n        log.Fatal(err)\n    }\n    \n    // Generate report\n    reporter := goresttest.NewReporter()\n    reporter.PrintConsoleReport(results)\n}\n```\n\n### Test Configuration Format\n\n```yaml\nname: \"API Test Suite\"\nbase_url: \"https://api.example.com\"\nvariables:\n  user_id: \"123\"\n  api_key: \"your-api-key\"\nparallel: true\nmax_workers: 5\n\ntests:\n  - name: \"Get User\"\n    method: \"GET\"\n    url: \"/users/${user_id}\"\n    headers:\n      Authorization: \"Bearer ${api_key}\"\n    assertions:\n      - type: \"status_code\"\n        expected: 200\n      - type: \"json_path\"\n        path: \"$.id\"\n        expected: 123\n      - type: \"response_time\"\n        expected: 1000\n        operator: \"less_than\"\n    extract:\n      username: \"json:$.username\"\n  \n  - name: \"Update User\"\n    method: \"PUT\"\n    url: \"/users/${user_id}\"\n    headers:\n      Authorization: \"Bearer ${api_key}\"\n      Content-Type: \"application/json\"\n    body: '{\"name\": \"Updated Name\"}'\n    assertions:\n      - type: \"status_code\"\n        expected: 200\n      - type: \"json_path\"\n        path: \"$.name\"\n        expected: \"Updated Name\"\n```\n\n## Assertion Types\n\n### Status Code\n```yaml\n- type: \"status_code\"\n  expected: 200\n  operator: \"equals\"  # equals, not_equals, greater_than, less_than\n```\n\n### JSON Path\n```yaml\n- type: \"json_path\"\n  path: \"$.data.users[0].name\"\n  expected: \"John Doe\"\n  operator: \"equals\"  # equals, not_equals, contains, not_contains\n```\n\n### HTML Selector\n```yaml\n- type: \"css_selector\"\n  path: \"h1.title\"\n  expected: \"Welcome\"\n```\n\n### Header\n```yaml\n- type: \"header\"\n  path: \"Content-Type\"\n  expected: \"application/json\"\n```\n\n### Body Contains\n```yaml\n- type: \"body_contains\"\n  expected: \"success\"\n  operator: \"contains\"  # contains, not_contains\n```\n\n### Regex\n```yaml\n- type: \"regex\"\n  expected: \"\\\\d{3}-\\\\d{2}-\\\\d{4}\"\n  operator: \"matches\"  # matches, not_matches\n```\n\n### Response Time\n```yaml\n- type: \"response_time\"\n  expected: 1000\n  operator: \"less_than\"  # less_than, greater_than, equals\n```\n\n## Variable Extraction\n\nExtract data from responses for use in subsequent tests:\n\n```yaml\nextract:\n  user_id: \"json:$.id\"                    # Extract from JSON response\n  session_token: \"header:X-Session-Token\"  # Extract from response header\n  csrf_token: \"regex:\u003cinput name=\\\"_token\\\" value=\\\"([^\\\"]+)\\\"\"  # Extract using regex\n  title: \"css:h1.title\"                    # Extract using CSS selector\n  status_code: \"status:\"                   # Extract status code\n  response_time: \"response_time:\"          # Extract response time\n```\n\n## Test Dependencies\n\nDefine test execution order:\n\n```yaml\ntests:\n  - name: \"Login\"\n    method: \"POST\"\n    url: \"/auth/login\"\n    # ... test definition\n\n  - name: \"Get Profile\"\n    method: \"GET\"\n    url: \"/profile\"\n    depends_on:\n      - \"Login\"\n    # ... test definition\n```\n\n## Programmatic Usage\n\n### Creating Tests Programmatically\n\n```go\ntest := goresttest.Test{\n    Name:   \"Create User\",\n    Method: \"POST\",\n    URL:    \"/users\",\n    Headers: map[string]string{\n        \"Content-Type\": \"application/json\",\n    },\n    Body: `{\"name\": \"John Doe\", \"email\": \"john@example.com\"}`,\n    Assertions: []goresttest.Assertion{\n        {\n            Type:     \"status_code\",\n            Expected: 201,\n        },\n        {\n            Type:     \"json_path\",\n            Path:     \"$.name\",\n            Expected: \"John Doe\",\n        },\n    },\n    Extract: map[string]string{\n        \"user_id\": \"json:$.id\",\n    },\n}\n\nrunner := goresttest.NewTestRunner(\"https://api.example.com\")\nresult, err := runner.RunTest(test, nil)\n```\n\n### Using Test Results\n\n```go\nif result.Success {\n    fmt.Printf(\"Test passed in %v\\n\", result.Duration)\n    fmt.Printf(\"Status Code: %d\\n\", result.StatusCode)\n    fmt.Printf(\"Extracted Variables: %v\\n\", result.Variables)\n} else {\n    fmt.Printf(\"Test failed: %s\\n\", result.Error)\n}\n```\n\n## Advanced Features\n\n### Custom HTTP Client Configuration\n\n```go\nrunner := goresttest.NewTestRunner(\"https://api.example.com\")\n// Access the underlying HTTP client if needed\n// runner.executor.client.client.Timeout = 30 * time.Second\n```\n\n### Variable Interpolation\n\nVariables can be used in:\n- URLs: `/users/${user_id}`\n- Headers: `Authorization: Bearer ${token}`\n- Request bodies: `{\"userId\": \"${user_id}\"}`\n- Assertion values: `expected: \"${expected_name}\"`\n- File paths: `body_file: \"${data_dir}/request.json\"`\n\n### Parallel Execution\n\n```yaml\nparallel: true\nmax_workers: 10\n```\n\nOr via CLI:\n```bash\ngoresttest -config tests.yaml -parallel -workers 10\n```\n\n## Examples\n\nSee the [examples](examples/) directory for complete working examples:\n\n- [library_usage.go](examples/library_usage.go) - Comprehensive library usage examples\n- [api_tests.yml](examples/api_tests.yml) - Sample test configuration\n\n## Development\n\n### Running Tests\n\n```bash\ngo test -v\n```\n\n### Building CLI\n\n```bash\ngo build ./cmd/goresttest\n```\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-sumeet%2Fgoresttest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-sumeet%2Fgoresttest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-sumeet%2Fgoresttest/lists"}