awesome-repositories.com
Blog
awesome-repositories.com

Descoperă cele mai bune repository-uri open source cu căutare AI.

ExploreazăCăutări recomandateAlternative open-sourceSoftware self-hostedBlogHartă site
ProiectDespreCum realizăm clasamentulPresăServer MCP
LegalConfidențialitateTermeni
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
DATA-DOG avatar

DATA-DOG/go-sqlmock

0
View on GitHub↗
6,525 stele·405 fork-uri·Go·other·4 vizualizări

Go Sqlmock

go-sqlmock is a Go library that simulates SQL driver behavior for unit testing by intercepting database calls through the standard database/sql/driver interface, eliminating the need for a real database connection. It provides a comprehensive mocking framework that allows developers to define expectations for SQL operations, including queries, executions, prepared statements, and transaction lifecycles, with precise control over the results and errors returned.

The library distinguishes itself through its flexible matching and verification capabilities. It supports regex-based or exact SQL string matching, along with a custom argument matching interface that handles complex types like time.Time and provides wildcard matchers for flexible value comparison. Expectations can be enforced in a predefined order, and the library verifies that all registered expectations are fulfilled during the test, reporting any unmatched or missing calls. It also includes configurable delayed response simulation for testing timeout and context cancellation scenarios.

Beyond core query and exec mocking, go-sqlmock covers the full spectrum of database interaction testing. This includes simulating connection health through ping calls and sentinel errors, managing transaction begin/commit/rollback cycles with configurable errors, and building mock result sets with detailed column metadata such as names, types, nullability, and precision. The library also supports multiple result sets, named parameters, and session state reset, providing a complete toolkit for validating database interaction logic in Go tests.

Features

  • Mock Driver Implementations - Intercepts database calls by implementing the database/sql/driver interfaces to simulate SQL driver behavior.
  • Database Interaction Mocking - Simulates SQL driver behavior in tests by intercepting database calls through the standard database/sql interface.
  • SQL Mocking Libraries - Simulate any SQL driver behavior in tests by intercepting database calls through the database/sql/driver interface without requiring a real database connection.
  • SQL Pattern Matchers - Validates SQL query strings and arguments using regex, equality, or custom matchers in tests.
  • Equality SQL Matchers - Validates incoming SQL strings against expected patterns using either regular expression or exact case-sensitive matching.
  • Mock Transaction Lifecycles - Set expectations for Begin, Commit, and Rollback calls, optionally returning errors or delays to test transaction handling.
  • Mock Result Set Builders - Creates mock result objects with configurable LastInsertId and RowsAffected values or error returns.
  • Custom Result Returns - Configure mocked queries and execs to return specific row sets, last insert IDs, affected row counts, or errors.
  • Error Simulators - Configures specific errors to be returned from any database operation to test error handling paths.
  • SQL Query Execution - Executes SQL statements that return no rows and reports the number of affected rows.
  • Mock Row Queries - Runs statements that return rows and provides an iterator over the result set for testing.
  • Exec Statement Mocking - Expects Exec or ExecContext calls, returning configurable results or errors, with optional argument matching.
  • Query Statement Mocking - Expects Query, QueryRow, or their context variants, returning configurable rows or errors, with optional argument matching.
  • Database Transaction Management - Provides a mocking framework for programmatic control of database transaction boundaries in tests.
  • Prepared Statements - Parses and stores query strings for repeated execution with different arguments.
  • Mocking Frameworks - Expect Prepare calls and define subsequent Exec or Query expectations on the prepared statement, optionally simulating close errors.
  • Mock Execution Mode Handlers - Returns predefined results or errors when matching INSERT/UPDATE/DELETE statements are executed with argument validation.
  • Statement Executions - Runs SQL statements that do not return rows, such as INSERT or UPDATE operations.
  • Transaction Management - Starts, commits, or rolls back transactions on a database connection.
  • Mock Argument Matchers - Match query or exec arguments using custom logic, including a wildcard matcher for any value or type-specific matchers like time.Time.
  • Database Type Converters - Ships a custom type conversion system for mapping Go values to database-compatible types in mock operations.
  • Database Argument Matchers - Provides custom argument matchers for comparing complex types like time.Time in database query expectations.
  • SQL Query String Matchers - Validates incoming SQL queries using regular expressions, exact equality, or custom matchers for flexible assertion control.
  • Database Ping Simulators - Mocks database ping calls to verify connectivity checks without a real database.
  • Interaction Expectations - Check that every registered expectation was fulfilled during the test and report any unmatched or missing calls.
  • SQL Statement Expectation Registries - Registers expected SQL INSERT, UPDATE, or DELETE statements with argument matching and configurable results.
  • Query Statement Expectations - Define expected Query calls with argument matching, returning custom rows or errors to test select operations.
  • Mocked SQL Results - Returns predefined results or errors for SQL operations, including row sets, affected row counts, last insert IDs, and custom errors.
  • Mock Response Delays - Introduces configurable time delays before returning results for any expected database operation.
  • SQL Query Verifications - Validating that SQL queries, arguments, and execution order match expected patterns during automated testing.
  • Database Connection Close Mocks - Expects Close calls on the database connection and returns configurable errors.
  • Customizable SQL Matchers - Replace default regex-based SQL matching with equality matching or a fully custom query matcher for sophisticated validation.
  • Database Operation Delays - Delays the response of SQL operations by a specified duration to test timeouts and context cancellation behavior.
  • Health Validation - Signal whether a connection is still valid before it is returned to or reused from the connection pool.
  • Bad Connection Signaling - Return a sentinel error to indicate a connection is invalid so the pool can discard and retry it.
  • Connection Health Simulators - Simulates database connection health scenarios including pings, errors, and session resets for pool testing.
  • Ping Output Normalization - Observes and mocks database ping calls to verify connection health checks in tests.
  • Column Metadata Retrieval - Reports column names, types, nullability, length, precision, and scale for query result sets.
  • Mock Column Metadata Builders - Builds mock column metadata with type, nullability, and precision details for simulating query results.
  • Ordered - Enforces that database operations occur in a predefined sequence by tracking expectation order.
  • Response Simulators - Adds configurable delays to any expected database operation to test timeout and context cancellation behavior.
  • Mocking Tools - Mock SQL driver for testing database interactions.
  • Testing and QA - SQL mock for database interaction testing.
  • Testing and Quality Assurance - SQL mock for database interaction testing.
  • Framework-uri de testare - SQL mocking library.

Istoric stele

Graficul istoricului de stele pentru data-dog/go-sqlmockGraficul istoricului de stele pentru data-dog/go-sqlmock

Căutare AI

Explorează mai multe repository-uri excelente

Descrie ce ai nevoie în limbaj simplu — AI-ul sortează mii de proiecte open source selectate în funcție de relevanță.

Start searching with AI

Întrebări frecvente

Ce face data-dog/go-sqlmock?

go-sqlmock is a Go library that simulates SQL driver behavior for unit testing by intercepting database calls through the standard database/sql/driver interface, eliminating the need for a real database connection. It provides a comprehensive mocking framework that allows developers to define expectations for SQL operations, including queries, executions, prepared statements, and transaction lifecycles, with precise control over the results and errors returned.

Care sunt principalele funcționalități ale data-dog/go-sqlmock?

Principalele funcționalități ale data-dog/go-sqlmock sunt: Mock Driver Implementations, Database Interaction Mocking, SQL Mocking Libraries, SQL Pattern Matchers, Equality SQL Matchers, Mock Transaction Lifecycles, Mock Result Set Builders, Custom Result Returns.

Care sunt câteva alternative open-source pentru data-dog/go-sqlmock?

Alternativele open-source pentru data-dog/go-sqlmock includ: rusqlite/rusqlite — Rusqlite is an embedded database interface and relational database driver that provides a client library for… doctrine/dbal — This project is a SQL database abstraction layer that provides a consistent object-oriented interface for interacting… jeremyevans/sequel — Sequel is a relational database toolkit for Ruby that provides object-relational mapping, a fluent SQL query builder,… beekeeper-studio/beekeeper-studio — Beekeeper Studio is a cross-platform desktop application designed for database management and SQL development. It… lib/pq — pq is a PostgreSQL driver for Go that implements the standard database/sql interface. It serves as a connection… golang/mock — GoMock is a mocking framework for the Go programming language.

Alternative open-source pentru Go Sqlmock

Proiecte open-source similare, clasificate după numărul de funcționalități comune cu Go Sqlmock.
  • rusqlite/rusqliteAvatar rusqlite

    rusqlite/rusqlite

    4,058Vezi pe GitHub↗

    Rusqlite is an embedded database interface and relational database driver that provides a client library for interacting with SQLite. It functions as an SQL query wrapper, enabling the management of local file-based or in-memory databases through a safe interface. The library allows for the extension of native database capabilities by implementing custom scalar functions, collations, and virtual tables. It also supports the embedding of the database engine directly into the application binary to remove external library dependencies. The project covers a broad range of capabilities including

    Rustbindingsrustsqlite
    Vezi pe GitHub↗4,058
  • doctrine/dbalAvatar doctrine

    doctrine/dbal

    9,699Vezi pe GitHub↗

    This project is a SQL database abstraction layer that provides a consistent object-oriented interface for interacting with multiple relational database systems. It includes a driver wrapper to standardize connections and result sets, a fluent query builder for constructing portable SQL statements, and a type mapper for converting database-specific data types into native application types and vice versa. The library enables programmatic schema management through a schema manager that can introspect database metadata, model structures as objects, and generate the SQL required to migrate between

    PHPdatabaseibm-db2mariadb
    Vezi pe GitHub↗9,699
  • jeremyevans/sequelAvatar jeremyevans

    jeremyevans/sequel

    5,076Vezi pe GitHub↗

    Sequel is a relational database toolkit for Ruby that provides object-relational mapping, a fluent SQL query builder, and schema migration capabilities. It maps database tables to Ruby classes with support for associations, validations, lifecycle hooks, and eager loading, offering a comprehensive ORM layer for building data-centric applications. Sequel distinguishes itself through a plugin-based extension architecture that allows composable customization of models, databases, and datasets without relying on deep inheritance hierarchies. It includes a thread-safe connection pool with support f

    Ruby
    Vezi pe GitHub↗5,076
  • beekeeper-studio/beekeeper-studioAvatar beekeeper-studio

    beekeeper-studio/beekeeper-studio

    22,030Vezi pe GitHub↗

    Beekeeper Studio is a cross-platform desktop application designed for database management and SQL development. It provides a unified graphical interface to connect to, query, and modify data across a wide range of relational and NoSQL database systems. The application functions as a comprehensive workspace, integrating tools for schema design, record editing, and data visualization. The project distinguishes itself through a focus on secure, flexible connectivity and AI-assisted workflows. It supports advanced authentication methods, including enterprise single sign-on, multi-factor authentic

    TypeScriptbigquerycassandracockroachdb
    Vezi pe GitHub↗22,030
  • Vezi toate cele 30 alternative pentru Go Sqlmock→