How to mock DB for unit tests?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

InfluxDB – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
Sevalla - Deploy and host your apps and databases, now with $50 credit!
Sevalla is the PaaS you have been looking for! Advanced deployment pipelines, usage-based pricing, preview apps, templates, human support by developers, and much more!
sevalla.com
featured
  1. go-sqlmock

    Sql mock driver for golang to test database interactions

    I've never bothered with any ORM, but for mocking the underlying sql.DB I've been using https://github.com/DATA-DOG/go-sqlmock which is very simple and straightforward to use.

  2. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  3. gnomock

    Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻

    You could check out Gnomock (https://github.com/orlangure/gnomock). It offers a different approach than what you asked, but maybe it'll suit your use case. It allows to easily setup a real DB like postgres in a docker container and then delete ot when tests are done.

  4. IAGD-Onlinesync

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Integration tests with Go and testcontainers

    6 projects | dev.to | 23 Jul 2022
  • Functional Programming in Go

    2 projects | news.ycombinator.com | 8 Nov 2024
  • Leverage Your Test Suite With testcontainers-go & docker-compose

    4 projects | dev.to | 4 Oct 2024
  • Integration Tests in Go with Cucumber, Testcontainers, and HTTPMock

    4 projects | dev.to | 11 Sep 2024
  • I Write Tests in Go

    1 project | news.ycombinator.com | 10 Apr 2024

Did you know that Go is
the 4th most popular programming language
based on number of references?