{"id":42951599,"url":"https://github.com/tryvium-travels/memongo","last_synced_at":"2026-01-30T21:12:54.269Z","repository":{"id":38366741,"uuid":"397408241","full_name":"tryvium-travels/memongo","owner":"tryvium-travels","description":"Easily run an in-memory MongoDB server for your Go unit tests","archived":false,"fork":false,"pushed_at":"2024-03-17T11:32:56.000Z","size":128,"stargazers_count":60,"open_issues_count":0,"forks_count":14,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-18T16:25:16.125Z","etag":null,"topics":["golang","mocking","mongo","mongo-memory-server","mongodb","test","travel","tryvium","tryvium-travels","unit-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/tryvium-travels.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-08-17T22:40:17.000Z","updated_at":"2024-05-30T11:32:13.000Z","dependencies_parsed_at":"2023-02-03T07:46:15.291Z","dependency_job_id":"7384fc24-0aed-4d4e-a39a-b52a1c75481e","html_url":"https://github.com/tryvium-travels/memongo","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/tryvium-travels/memongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryvium-travels%2Fmemongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryvium-travels%2Fmemongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryvium-travels%2Fmemongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryvium-travels%2Fmemongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tryvium-travels","download_url":"https://codeload.github.com/tryvium-travels/memongo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryvium-travels%2Fmemongo/sbom","scorecard":{"id":900310,"data":{"date":"2025-08-11","repo":{"name":"github.com/tryvium-travels/memongo","commit":"f21de184c9246a7747ac56bfe80a9c4b00481d9d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":5,"reason":"Found 9/16 approved changesets -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:17","Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:16","Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/codeql-analysis.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/go.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/tryvium-travels/memongo/go.yml/main?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 25 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0968 / GHSA-gwc9-m7rh-j2ww","Warn: Project is vulnerable to: GO-2021-0356 / GHSA-8c26-wmh5-6g9v","Warn: Project is vulnerable to: GO-2024-2961","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2021-0113 / GHSA-ppp9-7jff-5vj2","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T15:19:55.939Z","repository_id":38366741,"created_at":"2025-08-24T15:19:55.939Z","updated_at":"2025-08-24T15:19:55.939Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28919470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T20:25:28.696Z","status":"ssl_error","status_checked_at":"2026-01-30T20:25:13.426Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["golang","mocking","mongo","mongo-memory-server","mongodb","test","travel","tryvium","tryvium-travels","unit-testing"],"created_at":"2026-01-30T21:12:53.739Z","updated_at":"2026-01-30T21:12:54.261Z","avatar_url":"https://github.com/tryvium-travels.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Memongo logo](assets/logo.png)\n\n# memongo\n\n[![CI](https://github.com/tryvium-travels/memongo/workflows/Go/badge.svg)](https://github.com/tryvium-travels/memongo/actions?workflow=Go) [![GoDoc](https://godoc.org/github.com/tryvium-travels/memongo?status.svg)](https://godoc.org/github.com/tryvium-travels/memongo) [![Go Report Card](https://goreportcard.com/badge/github.com/tryvium-travels/memongo)](https://goreportcard.com/report/github.com/tryvium-travels/memongo)\n\n\u003e ***NOTE: This project started as a fork of [benweissmann/memongo project](https://github.com/benweissmann/memongo), but rapidly evolved to its own. While we thank and credit original creator for the job so far, we are going separate ways for the time being.***\n\u003e \n\u003e ***This is the only memongo library officially supported and maintained by Tryvium Travels LTD***\n\n`memongo` is a Go package that spins up a real MongoDB server, backed by in-memory\nstorage, for use in testing and mocking during development. It's based on\n[mongodb-memory-server](https://github.com/nodkz/mongodb-memory-server) for\nNodeJS.\n\nIn general, it's better to mock out interaction with the database, so you don't\nneed to run a Mongo server during testing. But becuase most Mongo clients use\na fluent interface that's tough to mock, and sometimes you need to test the\nqueries themselves, it's often helpful to be able to spin up a Mongo server\nquickly and easily. That's where `memongo` comes in!\n\n# Project Status\n\nBeta. Tests and CI are set up and working, but more esoteric configurations may not work. If Memongo isn't working on your platform, you might want to use `memongo.StartWithOptions()` and pass the correct download URL for your platform manually.\n\n# Caveats and Notes\n\nCurrently, `memongo` only supports UNIX systems. CI will run on MacOS, Ubuntu Xenial, Ubuntu Trusty, and Ubuntu Precise. Other flavors of Linux may or may not work.\n\n# Basic Usage\n\nSpin up a server for a single test:\n\n```go\nfunc TestSomething(t *testing.T) {\n  mongoServer, err := memongo.Start(\"4.0.5\")\n  if (err != nil) {\n    t.Fatal(err)\n  }\n  defer mongoServer.Stop()\n\n  connectAndDoStuff(mongoServer.URI(), memongo.RandomDatabase())\n}\n```\n\nSpin up a server, shared between tests:\n\n```go\nvar mongoServer memongo.Server;\n\nfunc TestMain(m *testing.M) {\n  mongoServer, err = memongo.Start(\"4.0.5\")\n  if (err != nil) {\n    log.Fatal(err)\n  }\n  defer mongoServer.Stop()\n\n  os.Exit(m.Run())\n}\n\nfunc TestSomething(t *testing.T) {\n  connectAndDoStuff(mongoServer.URI(), memongo.RandomDatabase())\n}\n```\n\nSpin up a replica set server:\n\n```go\nvar mongoServer memongo.Server;\n\nfunc TestMain(m *testing.M) {\n  mongoServer, err = memongo.StartWithOptions(\u0026memongo.Options{MongoVersion: \"4.2.1\", ShouldUseReplica: true})\n  if (err != nil) {\n    log.Fatal(err)\n  }\n  defer mongoServer.Stop()\n\n  os.Exit(m.Run())\n}\n\nfunc TestSomething(t *testing.T) {\n  connectAndDoStuff(mongoServer.URI(), memongo.RandomDatabase())\n}\n```\n\n# How it works\n\nBehind the scenes, when you run `Start()`, a few things are happening:\n\n1. If you specified a MongoDB version number (rather than a URL or binary path),\n   `memongo` detects your operating system and platform to determine the\n   download URL for the right MongoDB binary.\n\n2. If you specified a MongoDB version number or download URL, `memongo`\n   downloads MongoDB to a cache location. For future runs, `memongo` will just\n   use the copy from the cache. You only need to be connected to the internet\n   the first time you run `Start()` for a particular MongoDB version.\n\n3. `memongo` starts a process running the downloaded `mongod` binary. It uses\n   the `ephemeralForTest` storage engine, a temporary directory for a `dbpath`,\n   and a random free port number.\n\n4. `memongo` also starts up a \"watcher\" process. This process is a simple\n   portable shell script that kills the `mongod` process when the current\n   process exits. This ensures that we don't leave behind `mongod` processes,\n   even if your tests exit uncleanly or you don't call `Stop()`.\n\n# Configuration\n\nThe behavior of `memongo` can be controlled by using\n`memongo.StartWithOptions` instead of `memongo.Start`. See\n[the godoc](https://godoc.org/github.com/tryvium-travels/memongo) for all the options. Many options can also be set via environment variable.\n\nA few common use-cases are covered here:\n\nNote that you must use MongoDB version 3.2 or greater, because the `ephemeralForTest` storage engine was not present before 3.2.\n\n## Set the cache path\n\n`memongo` downloads a pre-compiled binary of MongoDB from https://www.mongodb.org and caches it on your local system. This path is set by (in order of preference):\n\n- The `CachePath` passed to `memongo.StartWithOptions`\n- The environment variable `MEMONGO_CACHE_PATH`\n- If `XDG_CACHE_HOME` is set, `$XDG_CACHE_HOME/memongo`\n- `~/.cache/memongo` on Linux, or `~/Library/Caches/memongo` on MacOS\n\n## Override download URL\n\nBy default, `memongo` tries to detect the platform you're running on and download an official MongoDB release for it. If `memongo` doesn't yet support your platform, of you'd like to use a custom version of MongoDB, you can pass `DownloadURL` to `memongo.StartWithOptions` or set the environment variable `MEMONGO_DOWNLOAD_URL`.\n\n`memongo`'s caching will still work with custom download URLs.\n\n## Use a custom MongoDB binary\n\nIf you'd like to bypass `memongo`'s download beahvior entirely, you can pass `MongodBin` to `memongo.StartWithOptions`, or set the environment variable `MEMONGO_MONGOD_BIN` to the path to a `mongod` binary. `memongo` will use this binary instead of downloading one.\n\nIf you're running on a platform that doesn't have an official MongoDB release (such as Alpine), you'll need to use this option.\n\n## Reduce or increase logging\n\nBy default, `memongo` logs at an \"info\" level. You may call `StartWithOptions` with `LogLevel: memongolog.LogLevelWarn` for fewer logs, `LogLevel: memongolog.LogLevelSilent` for no logs, or `LogLevel: memongolog.LogLevelDebug` for verbose logs (including full logs from MongoDB).\n\nBy default, `memongo` logs to stdout. To log somewhere else, specify a `Logger` in `StartWithOptions`.\n\n### Known bugs with Apple Silicon M1\n\nmacOS running on Apple silicon (`GOOS darwin/arm64`) is a common, unsupported, platform. But as macOS will run MongoDB with Rosetta 2, you can still use `memongo` by specifying the download url.\n```go\nopts := \u0026memongo.Options{\n  MongoVersion: \"8.0.0\",\n}\nif runtime.GOARCH == \"arm64\" {\n  if runtime.GOOS == \"darwin\" {\n    // Only set the custom url as workaround for arm64 macs\n    opts.DownloadURL = \"https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-8.0.0.tgz\"\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryvium-travels%2Fmemongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryvium-travels%2Fmemongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryvium-travels%2Fmemongo/lists"}