testutils.go
testutils.go - Overview
-
Overview This file provides utility functions for setting up test environments with SQLite databases for the query service. It includes functions to create a new SQLite database, run migrations, and initialize the data access objects (DAOs) and dashboard components.
-
Detailed Documentation
Function: NewTestSqliteDB
- Purpose: Creates a new temporary SQLite database for testing, applies migrations, and returns the
SQLStore
instance along with the file path. - Parameters:
t
(*testing.T): The testing object, used for error reporting and cleanup.
- Returns:
sqlStore
(sqlstore.SQLStore): TheSQLStore
instance connected to the new SQLite database.testDBFilePath
(string): The file path of the created SQLite database.
Function: NewQueryServiceDBForTests
- Purpose: Creates a new SQLite database using
NewTestSqliteDB
, initializes the DAOs usingdao.InitDao
, and initializes the dashboards usingdashboards.InitDB
. - Parameters:
t
(*testing.T): The testing object, used for error reporting.
- Returns:
sqlStore
(sqlstore.SQLStore): The initializedSQLStore
instance.
-
Code Examples None
-
Clarity and Accuracy The documentation accurately reflects the code's functionality.
-
Markdown & MDX Perfection All markdown is properly formatted and escaped.
-
Edge Cases To Avoid Breaking MDX No MDX errors are present.
-
Getting Started Relevance Include in Getting Started: NO