Documentation ¶
Overview ¶
Package db is responsible for database access.
Index ¶
- Variables
- func GetDBInstance(databaseConfig model.Database) (db abstraction.Database, err error)
- type TestSuite
- func (ts TestSuite) CleanupStaleDataDeletesDeleted(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CleanupStaleDataDeletesUnconfirmed(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CleanupStaleDataReturnsErrorOnInvalidType(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateCommentNoReply(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateCommentReplyToAReply(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateCommentWithReply(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateCommentWrongReply(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateCommentWrongThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) CreateThreadUniqueViolation(t *testing.T, database abstraction.Database)
- func (ts TestSuite) DeleteComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) DeleteCommentDeletesReplies(t *testing.T, database abstraction.Database)
- func (ts TestSuite) DeleteCommentNotFound(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetAllComments(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetAllCommentsEmptyDatabase(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetAllCommentsGetsSoftDeletedComments(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetAllThreads(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetAllThreadsEmptyDatabase(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetCommentNotFound(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetCommentsByThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetCommentsByThreadEmptyThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetCommentsByThreadNoThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetThread(t *testing.T, database abstraction.Database)
- func (ts TestSuite) GetThreadNotFound(t *testing.T, database abstraction.Database)
- func (ts TestSuite) HardDeleteDeletesComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) HardDeleteDeletesReplies(t *testing.T, database abstraction.Database)
- func (ts TestSuite) HardDeleteNoSuchComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) SoftDelete(t *testing.T, database abstraction.Database)
- func (ts TestSuite) TestDataImport(t *testing.T, database abstraction.Database)
- func (ts TestSuite) UpdateComment(t *testing.T, database abstraction.Database)
- func (ts TestSuite) UpdateCommentNotFound(t *testing.T, database abstraction.Database)
Constants ¶
This section is empty.
Variables ¶
var TestFunctions []reflect.Value
TestFunctions is a list of database test functions used to test the drivers. If you want to add a test method, just follow this signature func (ts TestSuite) SomeName(t *testing.T, database abstraction.Database) It will then get automagically added to the tests functions by init method.
Functions ¶
func GetDBInstance ¶
func GetDBInstance(databaseConfig model.Database) (db abstraction.Database, err error)
GetDBInstance looks at the database config object and returns a corresponding database instance
Types ¶
type TestSuite ¶
type TestSuite struct { }
TestSuite contains all the functions that one needs to test database operations against.
func (TestSuite) CleanupStaleDataDeletesDeleted ¶
func (ts TestSuite) CleanupStaleDataDeletesDeleted(t *testing.T, database abstraction.Database)
CleanupStaleDataDeletesDeleted checks if deleted comments get deleted according to timeout
func (TestSuite) CleanupStaleDataDeletesUnconfirmed ¶
func (ts TestSuite) CleanupStaleDataDeletesUnconfirmed(t *testing.T, database abstraction.Database)
CleanupStaleDataDeletesUnconfirmed checks if unconfirmed comments get deleted according to timeout
func (TestSuite) CleanupStaleDataReturnsErrorOnInvalidType ¶
func (ts TestSuite) CleanupStaleDataReturnsErrorOnInvalidType(t *testing.T, database abstraction.Database)
CleanupStaleDataReturnsErrorOnInvalidType asserts that invalid cleanup typ checking does exist
func (TestSuite) CreateComment ¶
func (ts TestSuite) CreateComment(t *testing.T, database abstraction.Database)
CreateComment checks if we create the comment alright
func (TestSuite) CreateCommentNoReply ¶
func (ts TestSuite) CreateCommentNoReply(t *testing.T, database abstraction.Database)
CreateCommentNoReply checks if we return an error upon replying to a non existant reply to
func (TestSuite) CreateCommentReplyToAReply ¶
func (ts TestSuite) CreateCommentReplyToAReply(t *testing.T, database abstraction.Database)
CreateCommentReplyToAReply asserts that we only allow 2 levels of nesting by making sure that a reply to a reply will instead point to it's parent
func (TestSuite) CreateCommentWithReply ¶
func (ts TestSuite) CreateCommentWithReply(t *testing.T, database abstraction.Database)
CreateCommentWithReply checks if a comment with a proper reply to value gets created correctly
func (TestSuite) CreateCommentWrongReply ¶
func (ts TestSuite) CreateCommentWrongReply(t *testing.T, database abstraction.Database)
CreateCommentWrongReply asserts that upon providing a bad reply to value we turn a ErrWrongReplyTo
func (TestSuite) CreateCommentWrongThread ¶
func (ts TestSuite) CreateCommentWrongThread(t *testing.T, database abstraction.Database)
CreateCommentWrongThread asserts that we return an error upon trying to reply to a comment from another thread
func (TestSuite) CreateThread ¶
func (ts TestSuite) CreateThread(t *testing.T, database abstraction.Database)
CreateThread checks if a thread is correctly created
func (TestSuite) CreateThreadUniqueViolation ¶
func (ts TestSuite) CreateThreadUniqueViolation(t *testing.T, database abstraction.Database)
CreateThreadUniqueViolation checks if duplicate thread creation throws no errors
func (TestSuite) DeleteComment ¶
func (ts TestSuite) DeleteComment(t *testing.T, database abstraction.Database)
DeleteComment asserts that we actually soft delete a comment
func (TestSuite) DeleteCommentDeletesReplies ¶
func (ts TestSuite) DeleteCommentDeletesReplies(t *testing.T, database abstraction.Database)
DeleteCommentDeletesReplies asserts that deletes are cascaded
func (TestSuite) DeleteCommentNotFound ¶
func (ts TestSuite) DeleteCommentNotFound(t *testing.T, database abstraction.Database)
DeleteCommentNotFound asserts if ErrCommentNotFound is return upon deletion of a non existant comment
func (TestSuite) GetAllComments ¶
func (ts TestSuite) GetAllComments(t *testing.T, database abstraction.Database)
GetAllComments asserts that all comments are gotten correctly.
func (TestSuite) GetAllCommentsEmptyDatabase ¶
func (ts TestSuite) GetAllCommentsEmptyDatabase(t *testing.T, database abstraction.Database)
GetAllCommentsEmptyDatabase asserts that we return an empty dataset
func (TestSuite) GetAllCommentsGetsSoftDeletedComments ¶
func (ts TestSuite) GetAllCommentsGetsSoftDeletedComments(t *testing.T, database abstraction.Database)
GetAllCommentsGetsSoftDeletedComments checks if get all comments returns all the comments, even the deleted ones.
func (TestSuite) GetAllThreads ¶
func (ts TestSuite) GetAllThreads(t *testing.T, database abstraction.Database)
GetAllThreads asserts that we return all the threads correctly
func (TestSuite) GetAllThreadsEmptyDatabase ¶
func (ts TestSuite) GetAllThreadsEmptyDatabase(t *testing.T, database abstraction.Database)
GetAllThreadsEmptyDatabase asserts that no threads are returned if none exist
func (TestSuite) GetComment ¶
func (ts TestSuite) GetComment(t *testing.T, database abstraction.Database)
GetComment checks if the getComment operation actually gets the comment
func (TestSuite) GetCommentNotFound ¶
func (ts TestSuite) GetCommentNotFound(t *testing.T, database abstraction.Database)
GetCommentNotFound asserts that we return ErrCommentNotFound if a comment is not found on GetComment
func (TestSuite) GetCommentsByThread ¶
func (ts TestSuite) GetCommentsByThread(t *testing.T, database abstraction.Database)
GetCommentsByThread asserts that we get correct comments for a specific thread, aka only confirmed ones.
func (TestSuite) GetCommentsByThreadEmptyThread ¶
func (ts TestSuite) GetCommentsByThreadEmptyThread(t *testing.T, database abstraction.Database)
GetCommentsByThreadEmptyThread asserts that we return an empty array if the thread has no comments
func (TestSuite) GetCommentsByThreadNoThread ¶
func (ts TestSuite) GetCommentsByThreadNoThread(t *testing.T, database abstraction.Database)
GetCommentsByThreadNoThread asserts that we return ErrThreadNotFound if no thread is found
func (TestSuite) GetThread ¶
func (ts TestSuite) GetThread(t *testing.T, database abstraction.Database)
GetThread checks if a created thread is gotten alright
func (TestSuite) GetThreadNotFound ¶
func (ts TestSuite) GetThreadNotFound(t *testing.T, database abstraction.Database)
GetThreadNotFound asserts that we correctly get a response saying we're not finding the thread
func (TestSuite) HardDeleteDeletesComment ¶
func (ts TestSuite) HardDeleteDeletesComment(t *testing.T, database abstraction.Database)
HardDeleteDeletesComment asserts that the comment is deleted correctly
func (TestSuite) HardDeleteDeletesReplies ¶
func (ts TestSuite) HardDeleteDeletesReplies(t *testing.T, database abstraction.Database)
HardDeleteDeletesReplies checks if the replies get also hard deleted
func (TestSuite) HardDeleteNoSuchComment ¶
func (ts TestSuite) HardDeleteNoSuchComment(t *testing.T, database abstraction.Database)
HardDeleteNoSuchComment tests if hard delete returns an error on a comment that does not exist
func (TestSuite) SoftDelete ¶
func (ts TestSuite) SoftDelete(t *testing.T, database abstraction.Database)
SoftDelete checks if comments are soft deleted
func (TestSuite) TestDataImport ¶
func (ts TestSuite) TestDataImport(t *testing.T, database abstraction.Database)
TestDataImport tests the data import functionality for the database
func (TestSuite) UpdateComment ¶
func (ts TestSuite) UpdateComment(t *testing.T, database abstraction.Database)
UpdateComment checks if we update the comment alright
func (TestSuite) UpdateCommentNotFound ¶
func (ts TestSuite) UpdateCommentNotFound(t *testing.T, database abstraction.Database)
UpdateCommentNotFound asserts that we return ErrCommentNotFound upon updating a non existant comment
Directories ¶
Path | Synopsis |
---|---|
Package abstraction defines all the required interfaces to make the database layer pluggable.
|
Package abstraction defines all the required interfaces to make the database layer pluggable. |
Package dynamodb is responsible for connections and data manipulation on dynamodb
|
Package dynamodb is responsible for connections and data manipulation on dynamodb |
model
Package model deals with specific models for dynamodb(they might be a bit different to db/model).
|
Package model deals with specific models for dynamodb(they might be a bit different to db/model). |
Package model contains the models consumed by the databases.
|
Package model contains the models consumed by the databases. |
Package sqlxDriver allows for data manipulation through the github.com/jmoiron/sqlx package.
|
Package sqlxDriver allows for data manipulation through the github.com/jmoiron/sqlx package. |
mysql
Package mysql is responsible for mysql database connections and initialization.
|
Package mysql is responsible for mysql database connections and initialization. |
postgres
Package postgres is responsible for postgres database connections and initialization.
|
Package postgres is responsible for postgres database connections and initialization. |
sqlite
Package sqlite is responsible for sqlite database connections and initialization.
|
Package sqlite is responsible for sqlite database connections and initialization. |
Package tool contains various utilities used with the mouthful database
|
Package tool contains various utilities used with the mouthful database |