{"id":36851590,"url":"https://github.com/akhettar/docker-db","last_synced_at":"2026-01-12T14:38:01.224Z","repository":{"id":57522764,"uuid":"253827903","full_name":"akhettar/docker-db","owner":"akhettar","description":"Run DB as docker container for integration tests","archived":false,"fork":false,"pushed_at":"2020-04-27T08:32:36.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-20T03:32:21.169Z","etag":null,"topics":["database","docker-databases","integration-tests"],"latest_commit_sha":null,"homepage":null,"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/akhettar.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-04-07T15:02:50.000Z","updated_at":"2024-06-20T03:32:21.170Z","dependencies_parsed_at":"2022-08-30T01:40:35.054Z","dependency_job_id":null,"html_url":"https://github.com/akhettar/docker-db","commit_stats":null,"previous_names":["akhettar/docker-test"],"tags_count":28,"template":false,"template_full_name":null,"purl":"pkg:github/akhettar/docker-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhettar%2Fdocker-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhettar%2Fdocker-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhettar%2Fdocker-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhettar%2Fdocker-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akhettar","download_url":"https://codeload.github.com/akhettar/docker-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhettar%2Fdocker-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28340403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["database","docker-databases","integration-tests"],"created_at":"2026-01-12T14:38:00.396Z","updated_at":"2026-01-12T14:38:01.209Z","avatar_url":"https://github.com/akhettar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Test\n![Master CI](https://github.com/akhettar/docker-db/workflows/Master%20CI/badge.svg?branch=master)\n[![GoDoc](https://godoc.org/github.com/akhettar/docker-db?status.svg)](https://godoc.org/github.com/akhettar/docker-db)\n\n\n![hard working man](pushing-cart.png)\n\nThis is a Go library to run database containers as part of running the integration tests. The following databases are supported:\n\n* Postgres\n* MongoDB - DocumentDB\n\n# How to use\n\n## Running Postgres container\n\nAn example of running `postgres` container is present in this project. See the following files: \n* [Integratino test](docker_test.go)\n* [Test fixture](init_test.go)\n\n## Running MongoDB container\n\n`Integration test snipppet`\n\n```go\nfunc TestPublishAppStatus_WithInvalidAppPlatformReturnBadRequestResponse(t *testing.T) {\n\n\tt.Logf(\"Given the app status api is up and running\")\n\t{\n\t\tplatform := \"dummy\"\n\t\tt.Logf(\"\\tWhen Sending Publish App status request to endpoint with unsupported platform value:  \\\"%s\\\"\", platform)\n\t\t{\n\t\t\n            mockUnleash := test.GetMockUnleashClient(t)\n\t\t\thandler := NewAppStatusHandler(Repository, mockUnleash)\n\t\t\trouter := handler.CreateRouter()\n\t\t\tversion := \"1.0\"\n\n\t\t\tbody := model.ReleaseRequest{Version: version, Platform: platform}\n\t\t\treq, err := test.HttpRequest(body, \"/status\", http.MethodPost, test.ValidToken)\n\t\t\tw := httptest.NewRecorder()\n\t\t\trouter.ServeHTTP(w, req)\n\n\t\t\t// check call success\n\t\t\ttest.Ok(err, t)\n\n\t\t\tif w.Code == http.StatusBadRequest {\n\t\t\t\tt.Logf(\"\\t\\tShould receive a \\\"%d\\\" status. %v\", http.StatusBadRequest, test.CheckMark)\n\t\t\t} else {\n\t\t\t\tt.Errorf(\"\\t\\tShould receive a \\\"%d\\\" status. %v %v\", http.StatusBadRequest, test.BallotX, w.Code)\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\nIn the same package include a test file with the name: `init_test.go` and include the following\n\n```go\nimport (\n\t\"github.com/akhettar/app-features-manager/repository\"\n\t\"context\"\n\t\"flag\"\n\t\"github.com/akhettar/docker-db\"\n\t\"go.mongodb.org/mongo-driver/mongo\"\n\t\"go.mongodb.org/mongo-driver/mongo/options\"\n\t\"log\"\n\n\t\"net/http/httptest\"\n\t\"os\"\n\t\"testing\"\n)\n\nconst ProfileEnvVar = \"PROFILE\"\n\nvar (\n\t  \n  // The repository instance configured to run against the Docker DB Test container\n\tRepository *repository.MongoRepository\n\n)\n\n// TestFixture wraps all tests with the needed initialized mock DB and fixtures\n// This test runs before other integration test. It starts an instance of mongo db in the background (provided you have mongo\n// installed on the server on which this test will be running) and shuts it down.\nfunc TestMain(m *testing.M) {\n\n\tcontainer := dbtest.StartMongoContainer()\n\tlog.Printf(\"running mongo with Ip %s\", container.Host())\n\n\turi := fmt.Sprintf(\"mongodb://%s:%d\", container.Host(), container.Port())\n\tclientOptions := options.Client().ApplyURI(uri)\n\n\tclient, err := mongo.Connect(context.TODO(), clientOptions)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Check the connection\n\terr = client.Ping(context.TODO(), nil)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tRepository = \u0026repository.MongoRepository{client, repository.DBInfo{uri, repository.DefaultDBName, repository.DefaultCollection}}\n\n\t// Run the test suite\n\tretCode := m.Run()\n\n\tc.Destroy()\n\n\t// call with result of m.Run()\n\tos.Exit(retCode)\n}\n\n```\n\n# License\n[MIT](LICENSE)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhettar%2Fdocker-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakhettar%2Fdocker-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhettar%2Fdocker-db/lists"}