{"id":15270319,"url":"https://github.com/godogx/elasticsteps","last_synced_at":"2026-01-20T03:07:47.128Z","repository":{"id":37523358,"uuid":"423272168","full_name":"godogx/elasticsteps","owner":"godogx","description":"Cucumber ElasticSearch steps for Golang","archived":false,"fork":false,"pushed_at":"2024-03-01T20:27:10.000Z","size":301,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-05T19:20:04.334Z","etag":null,"topics":["bdd","cucumber","functional-testing","gherkin","go","godog","godog-extension","golang","integration-testing","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/godogx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-10-31T22:14:27.000Z","updated_at":"2024-12-20T06:41:38.000Z","dependencies_parsed_at":"2024-06-20T21:53:10.087Z","dependency_job_id":"e2c798ac-bd3e-4261-a7a2-a4f7d78b2ef0","html_url":"https://github.com/godogx/elasticsteps","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/godogx/elasticsteps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godogx%2Felasticsteps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godogx%2Felasticsteps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godogx%2Felasticsteps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godogx%2Felasticsteps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/godogx","download_url":"https://codeload.github.com/godogx/elasticsteps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/godogx%2Felasticsteps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28594958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"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":["bdd","cucumber","functional-testing","gherkin","go","godog","godog-extension","golang","integration-testing","testing"],"created_at":"2024-09-30T07:08:13.544Z","updated_at":"2026-01-20T03:07:47.103Z","avatar_url":"https://github.com/godogx.png","language":"Go","readme":"# Cucumber ElasticSearch steps for Golang\n\n[![GitHub Releases](https://img.shields.io/github/v/release/godogx/elasticsteps)](https://github.com/godogx/elasticsteps/releases/latest)\n[![Build Status](https://github.com/godogx/elasticsteps/actions/workflows/test.yaml/badge.svg)](https://github.com/godogx/elasticsteps/actions/workflows/test.yaml)\n[![codecov](https://codecov.io/gh/godogx/elasticsteps/branch/master/graph/badge.svg?token=eTdAgDE2vR)](https://codecov.io/gh/godogx/elasticsteps)\n[![Go Report Card](https://goreportcard.com/badge/github.com/godogx/elasticsteps)](https://goreportcard.com/report/github.com/godogx/elasticsteps)\n[![GoDevDoc](https://img.shields.io/badge/dev-doc-00ADD8?logo=go)](https://pkg.go.dev/github.com/godogx/elasticsteps)\n\n`elasticsteps` provides steps for [`cucumber/godog`](https://github.com/cucumber/godog) and makes it easy to run tests with ElasticSearch.\n\n## Prerequisites\n\n- `Go \u003e= 1.17`\n\n## Usage\n\n### Setup\n\nInitiate an `elasticsteps.Manager` and register it to the scenario using one of the supported drivers:\n\n| Driver | Constructor |\n| :--- | :---: |\n| [`elastic/go-elasticsearch/v7`](https://github.com/elastic/go-elasticsearch) | [`driver/go-elasticsearch/v7`](https://github.com/godogx/elasticsteps/blob/master/driver/go-elasticsearch/v7/manager.go#L10) |\n| [`olivere/elastic`](https://github.com/olivere/elastic) | ❌ |\n\n```go\npackage mypackage\n\nimport (\n\t\"bytes\"\n\t\"math/rand\"\n\t\"testing\"\n\n\t\"github.com/cucumber/godog\"\n\telasticsearch \"github.com/elastic/go-elasticsearch/v7\"\n\t\"github.com/stretchr/testify/require\"\n\n\telasticsearch7 \"github.com/godogx/elasticsteps/driver/go-elasticsearch/v7\"\n)\n\nfunc TestIntegration(t *testing.T) {\n\tout := bytes.NewBuffer(nil)\n\n\tes, err := elasticsearch.NewClient(elasticsearch.Config{\n\t\tAddresses: []string{\"127.0.0.1:9200\"},\n\t})\n\trequire.NoError(t, err)\n\n\t// Create a new grpc client.\n\tmanager := elasticsearch7.NewManager(es,\n\t\t// If you have another server, you could register it as well, for example:\n\t\t// elasticsearch7.WithInstance(\"another_instance\", es),\n\t)\n\n\tsuite := godog.TestSuite{\n\t\tName:                 \"Integration\",\n\t\tTestSuiteInitializer: nil,\n\t\tScenarioInitializer: func(ctx *godog.ScenarioContext) {\n\t\t\t// Register the client.\n\t\t\tmanager.RegisterContext(ctx)\n\t\t},\n\t\tOptions: \u0026godog.Options{\n\t\t\tStrict:    true,\n\t\t\tOutput:    out,\n\t\t\tRandomize: rand.Int63(),\n\t\t},\n\t}\n\n\t// Run the suite.\n\tif status := suite.Run(); status != 0 {\n\t\tt.Fatal(out.String())\n\t}\n}\n```\n\n### Steps\n\n#### Create a new index\n\nCreate a new index in the instance. If the index exists, the manager will throw an error.\n\n- `index \"([^\"]*)\" is created$`\n- `index \"([^\"]*)\" is created in es \"([^\"]*)\"$` (if you want to create in the other instance)\n\nFor example:\n\n```gherkin\nGiven index \"products\" is created\n```\n\nYou could create a new index with a custom config by running:\n - `index \"([^\"]*)\" is created with config[:]?$`\n - `index \"([^\"]*)\" is created in es \"([^\"]*)\" with config[:]?$`\n - `index \"([^\"]*)\" is created with config from file[:]?$`\n - `index \"([^\"]*)\" is created in es \"([^\"]*)\" with config from file[:]?$`\n\nFor example:\n\n```gherkin\nGiven index \"products\" is created with config:\n\"\"\"\n{\n    \"mappings\": {\n        \"properties\": {\n            \"size\": {\n                \"type\": \"integer\"\n            },\n            \"name\": {\n                \"type\": \"keyword\"\n            },\n            \"description\": {\n                \"type\": \"text\"\n            }\n        }\n    }\n}\n\"\"\"\n```\n\nor\n\n```gherkin\nGiven index \"products\" is created with config from file:\n\"\"\"\n../../resources/fixtures/mapping.json\n\"\"\"\n```\n\n#### Recreate an index\n\nCreate a new index in the instance if it does not exist, otherwise the index will be deleted and recreated.\n\n- `index \"([^\"]*)\" is recreated$`\n- `there is (?:an )?index \"([^\"]*)\"$`\n- `index \"([^\"]*)\" is recreated in es \"([^\"]*)\"$` (if you want to recreate in the other instance)\n- `there is (?:an )?index \"([^\"]*)\" in es \"([^\"]*)\"$` (if you want to recreate in the other instance)\n\nFor example:\n\n```gherkin\nGiven index \"products\" is recreated\n```\n\nor\n\n```gherkin\nGiven there is index \"products\"\n```\n\nSame as [#Create a new index](#Create a new index), you could recreate an index with a custom config:\n- Inline\n  - `index \"([^\"]*)\" is recreated with config[:]?$`\n  - `there is (?:an )?index \"([^\"]*)\" with config[:]?$`\n- From a file\n  - `index \"([^\"]*)\" is recreated with config from file[:]?$`\n  - `there is (?:an )?index \"([^\"]*)\" with config from file[:]?$`\n- Inline (for other instances)\n  - `index \"([^\"]*)\" is recreated in es \"([^\"]*)\" with config[:]?$`\n  - `there is (?:an )?index \"([^\"]*)\" in es \"([^\"]*)\" with config[:]?$`\n- From a file (for other instances)\n  - `index \"([^\"]*)\" is recreated in es \"([^\"]*)\" with config from file[:]?$`\n  - `there is (?:an )?index \"([^\"]*)\" in es \"([^\"]*)\" with config from file[:]?$`\n\n#### Delete an index\n\nDelete an index in the instance. If the index does not exist, the manager will throw an error.\n\n- `no index \"([^\"]*)\"$`\n- `no index \"([^\"]*)\" in es \"([^\"]*)\"$` (if you want to delete in the other instance)\n\nFor example:\n\n```gherkin\nGiven no index \"products\"\n```\n\n#### Index Documents\n\n- `these docs are stored in index \"([^\"]*)\"[:]?$`\n- `these docs are stored in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$` (if you want to index in the other instance)\n\nFor example:\n\n```gherkin\nGiven these docs are stored in index \"products\":\n\"\"\"\n[\n    {\n        \"_id\": \"41\",\n        \"_source\": {\n            \"handle\": \"item-41\",\n            \"name\": \"Item 41\",\n            \"locale\": \"en_US\"\n        }\n    }\n]\n\"\"\"\n```\n\nYou can also send the docs from a file by using:\n- `docs (?:in|from) this file are stored in index \"([^\"]*)\"[:]?$`\n- `docs (?:in|from) this file are stored in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$` (if you want to index in the other instance)\n\nFor example:\n\n```gherkin\nGiven docs in this file are stored in index \"products\":\n\"\"\"\n../../resources/fixtures/products.json\n\"\"\"\n```\n\n#### Check whether an index exists\n\n- `index \"([^\"]*)\" exists$`\n- `index \"([^\"]*)\" exists in es \"([^\"]*)\"$` (if you want to check the other instance)\n\nFor example:\n\n```gherkin\nThen index \"products\" exists\n```\n\n#### Check whether an index does not exist\n\n- `index \"([^\"]*)\" does not exist$`\n- `index \"([^\"]*)\" does not exist in es \"([^\"]*)\"$` (if you want to check the other instance)\n\nFor example:\n\n```gherkin\nThen index \"products\" does not exist\n```\n\n#### Check there is no document in the index\n\n- `no docs are available in index \"([^\"]*)\"$`\n- `no docs are available in index \"([^\"]*)\" of es \"([^\"]*)\"$` (if you want to check the other instance)\n\nFor example:\n\n```gherkin\nThen no docs are available in index \"products\"\n```\n\n#### Check whether index contains the exact documents\n\n- `only these docs are available in index \"([^\"]*)\"[:]?$`\n- `only these docs are available in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$` (if you want to check the other instance)\n\nFor example:\n\n```gherkin\nThen only these docs are available in index \"products\":\n\"\"\"\n[\n    {\n        \"_id\": \"41\",\n        \"_source\": {\n            \"handle\": \"item-41\",\n            \"name\": \"Item 41\",\n            \"locale\": \"en_US\"\n        },\n        \"_score\": 1,\n        \"_type\": \"_doc\"\n    },\n    {\n        \"_id\": \"42\",\n        \"_source\": {\n            \"handle\": \"item-42\",\n            \"name\": \"Item 42\",\n            \"locale\": \"en_US\"\n        },\n        \"_score\": 1,\n        \"_type\": \"_doc\"\n    }\n]\n\"\"\"\n```\n\nYou can also get the expected docs from a file by using:\n- `only docs (?:in|from) this file are available in index \"([^\"]*)\"[:]?$`\n- `only docs (?:in|from) this file are available in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$` (if you want to index in the other instance)\n\nFor example:\n\n```gherkin\nGiven only docs in this file are available in index \"products\":\n\"\"\"\n../../resources/fixtures/result.json\n\"\"\"\n```\n\n#### Query documents\n\n- First step: Setup the query \u003cbr/\u003e\n  `I search in index \"([^\"]*)\" with query[:]?$` \u003cbr/\u003e\n  `I search in index \"([^\"]*)\" of es \"([^\"]*)\" with query[:]?$`\n- Second step: Check the result \u003cbr/\u003e\n  `these docs are found in index \"([^\"]*)\"[:]?$` \u003cbr/\u003e\n  `these docs are found in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$`\n\nFor example:\n\n```gherkin\nWhen I search in index \"products\" with query:\n\"\"\"\n{\n    \"query\": {\n        \"match\": {\n            \"locale\": \"en_US\"\n        }\n    }\n}\n\"\"\"\n\nThen these docs are found in index \"products\":\n\"\"\"\n[\n    {\n        \"_id\": \"41\",\n        \"_source\": {\n            \"handle\": \"item-41\",\n            \"name\": \"Item 41\",\n            \"locale\": \"en_US\"\n        },\n        \"_score\": \"\u003cignore-diff\u003e\",\n        \"_type\": \"_doc\"\n    },\n    {\n        \"_id\": \"42\",\n        \"_source\": {\n            \"handle\": \"item-42\",\n            \"name\": \"Item 42\",\n            \"locale\": \"en_US\"\n        },\n        \"_score\": \"\u003cignore-diff\u003e\",\n        \"_type\": \"_doc\"\n    }\n]\n\"\"\"\n```\n\nYou can also get the expected docs from a file by using:\n- `docs (?:in|from) this file are found in index \"([^\"]*)\"[:]?$`\n- `docs (?:in|from) this file are found in index \"([^\"]*)\" of es \"([^\"]*)\"[:]?$` (if you want to index in the other instance)\n\nFor example:\n\n```gherkin\nGiven docs in this file are found in index \"products\":\n\"\"\"\n../../resources/fixtures/result.json\n\"\"\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodogx%2Felasticsteps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodogx%2Felasticsteps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodogx%2Felasticsteps/lists"}