{"id":15688235,"url":"https://github.com/mkeeler/consul-mock-api","last_synced_at":"2025-05-07T21:02:42.705Z","repository":{"id":41812070,"uuid":"294723550","full_name":"mkeeler/consul-mock-api","owner":"mkeeler","description":"Consul Mock HTTP API helpers","archived":false,"fork":false,"pushed_at":"2022-12-15T17:28:44.000Z","size":31,"stargazers_count":9,"open_issues_count":3,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T11:41:41.232Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkeeler.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}},"created_at":"2020-09-11T14:53:12.000Z","updated_at":"2024-11-30T22:54:25.000Z","dependencies_parsed_at":"2023-01-29T04:00:32.532Z","dependency_job_id":null,"html_url":"https://github.com/mkeeler/consul-mock-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkeeler%2Fconsul-mock-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkeeler%2Fconsul-mock-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkeeler%2Fconsul-mock-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkeeler%2Fconsul-mock-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkeeler","download_url":"https://codeload.github.com/mkeeler/consul-mock-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954376,"owners_count":21830902,"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":[],"created_at":"2024-10-03T17:56:25.657Z","updated_at":"2025-05-07T21:02:42.646Z","avatar_url":"https://github.com/mkeeler.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# consul-mock-api\nConsul Mock HTTP API helpers\n\n## Usage\n\n```go\npackage somepkg\n\nimport (\n   \"testing\"\n\n   \"github.com/hashicorp/consul/api\"\n   mockconsul \"github.com/mkeeler/consul-mock-api\"\n)\n\nfunc TestTokenList(t *testing.T) {\n   m := mockconsul.NewConsul(t)\n\n   // http.Get will add both of the headers but we don't want to care about them.\n   m.SetFilteredHeaders([]string{\n      \"Accept-Encoding\",\n      \"User-Agent\",\n   })\n\n   // set up an expectation for a GET /v1/acl/tokens\n   m.ACLTokenList(200, []*api.ACLTokenListEntry{\n      CreateIndex: 1,\n      ModifyIndex: 2,\n      AccessorID:  \"cd45b25a-07cf-4a60-ae71-2a227eaace8e\",\n      Description: \"fake token\",\n      NodeIdentities: []*api.ACLNodeIdentity{\n         {\n             NodeName: \"foo\",\n             Datacenter: \"dc1\",\n         },\n      },\n   }).Once() // expect this call to be made exactly once\n   \n   cfg := api.DefaultConfig()\n   cfg.Address = m.URL()\n   \n   client, err := api.NewClient(cfg)\n   if err != nil {\n      t.Fatalf(\"error when creating a new HTTP client: %v\", err)\n   }\n   \n   tokens, _, err := client.ACL().TokenList(nil)\n   if err != nil {\n      t.Fatalf(\"error when retrieving token list: %v\", err)\n   }\n   \n   if len(tokens) != 1 {\n      t.Fatalf(\"wrong number of token returned - expected: 1, got: %d\", len(tokens))\n   }\n   \n   // no need to do anything if using Go 1.14 as the expectations will be checked \n   // and the test HTTP server will be closed automatically. If not using Go 1.14 then\n   // you should defer m.Close() after its creation\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkeeler%2Fconsul-mock-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkeeler%2Fconsul-mock-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkeeler%2Fconsul-mock-api/lists"}