{"id":20724659,"url":"https://github.com/arhea/go-mock-spanner","last_synced_at":"2025-06-21T03:40:34.206Z","repository":{"id":210428543,"uuid":"726520278","full_name":"arhea/go-mock-spanner","owner":"arhea","description":"Provides container based mock for Google Cloud Spanner so that you can unit test database code.","archived":false,"fork":false,"pushed_at":"2024-04-09T12:45:35.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-11T08:50:13.627Z","etag":null,"topics":["go","golang","golang-package","google-cloud","google-cloud-spanner","spanner","testcontainers","testcontainers-go","testcontainers-go-contrib"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/arhea/go-mock-spanner","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/arhea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["arhea"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-12-02T16:18:02.000Z","updated_at":"2023-12-15T16:05:47.000Z","dependencies_parsed_at":"2023-12-16T00:13:29.104Z","dependency_job_id":"446f2785-9892-42dd-b64f-bc1ff34fdd60","html_url":"https://github.com/arhea/go-mock-spanner","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"e64d7d12154907e76c494cb007d012211ee19bd7"},"previous_names":["arhea/go-mock-spanner"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/arhea/go-mock-spanner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhea%2Fgo-mock-spanner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhea%2Fgo-mock-spanner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhea%2Fgo-mock-spanner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhea%2Fgo-mock-spanner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arhea","download_url":"https://codeload.github.com/arhea/go-mock-spanner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arhea%2Fgo-mock-spanner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261059100,"owners_count":23103948,"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":["go","golang","golang-package","google-cloud","google-cloud-spanner","spanner","testcontainers","testcontainers-go","testcontainers-go-contrib"],"created_at":"2024-11-17T04:15:54.666Z","updated_at":"2025-06-21T03:40:29.186Z","avatar_url":"https://github.com/arhea.png","language":"Go","funding_links":["https://github.com/sponsors/arhea"],"categories":[],"sub_categories":[],"readme":"# Mock Google Cloud Spanner\n\n![Tests](https://github.com/arhea/go-mock-spanner/actions/workflows/main.yml/badge.svg?branch=main) ![goreportcard](https://goreportcard.com/badge/github.com/arhea/go-mock-spanner)\n\nProvides a mock of [Google Cloud Spanner](https://cloud.google.com/spanner?hl=en) using the official [Google Cloud Spanner Emulator](https://github.com/GoogleCloudPlatform/cloud-spanner-emulator).\n\nThese mocks will automatically create a new emulator, wait for it to be available, then create a mock database. You will need to run your database migrations prior to performing your tests.\n\nI recommend reusing the instance across multiple tests to reduce test run times.\n\nThis library is built on top of [testcontainers](https://testcontainers.com/).\n\n## Usage\n\nCreating a mock instance for creating a customer connection.\n\n```golang\nfunc TestXXX(t *testing.T) {\n\tctx := context.Background()\n\n\tmock, err := mockspanner.NewInstance(ctx, t)\n\n\tif err != nil {\n\t\tt.Fatalf(\"creating the instance: %v\", err)\n\t\treturn\n\t}\n\n\t// close the mock\n\tdefer mock.Close(ctx)\n\n\t// ... my test code\n}\n```\n\nCreating a mock Spanner client for interacting with Spanner via the Go client.\n\n```golang\nfunc TestXXX(t *testing.T) {\n\tctx := context.Background()\n\n\tmock, err := mockspanner.NewClient(ctx, t)\n\n\tif err != nil {\n\t\tt.Fatalf(\"creating the client: %v\", err)\n\t\treturn\n\t}\n\n\t// close the mock\n\tdefer mock.Close(ctx)\n\n    spannerClient := mock.Client()\n\n    t.Run(\"MyTest1\", func(t *testing.T) {\n        // ... my test code\n    })\n\n    t.Run(\"MyTest2\", func(t *testing.T) {\n        // ... my test code\n    })\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farhea%2Fgo-mock-spanner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farhea%2Fgo-mock-spanner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farhea%2Fgo-mock-spanner/lists"}