Merged in feature/functestcov (pull request #84)
Function Test Coverage * test * scripts
This commit is contained in:
@@ -8,13 +8,12 @@ import (
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestQueriesNew(t *testing.T) {
|
||||
pool, err := pgxmock.NewPool()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
queries := repository.New(pool)
|
||||
assert.NotNil(t, queries)
|
||||
@@ -24,9 +23,7 @@ func TestQueriesWithTx(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
pool, err := pgxmock.NewPool()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
queries := repository.New(pool)
|
||||
assert.NotNil(t, queries)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package repository_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestFailTypeScan(t *testing.T) {
|
||||
qType := repository.Cleanfailtype(fmt.Sprint(0))
|
||||
|
||||
stringType := "invalid_mimetype"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestNullFailTypeScan(t *testing.T) {
|
||||
qType := repository.NullCleanfailtype{}
|
||||
|
||||
stringType := "invalid_mimetype"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestNullFailTypeValue(t *testing.T) {
|
||||
qType := repository.NullCleanfailtype{}
|
||||
|
||||
stringType := "invalid_mimetype"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
|
||||
val, err := qType.Value()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, stringType, val)
|
||||
}
|
||||
|
||||
func TestFailTypeValid(t *testing.T) {
|
||||
assert.True(t, repository.CleanfailtypeInvalidMimetype.Valid())
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package repository_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestMimeTypeScan(t *testing.T) {
|
||||
qType := repository.Cleanmimetype(fmt.Sprint(0))
|
||||
|
||||
stringType := "application/pdf"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestNullMimeTypeScan(t *testing.T) {
|
||||
qType := repository.NullCleanmimetype{}
|
||||
|
||||
stringType := "application/pdf"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestNullMimeTypeValue(t *testing.T) {
|
||||
qType := repository.NullCleanmimetype{}
|
||||
|
||||
stringType := "application/pdf"
|
||||
err := qType.Scan(stringType)
|
||||
assert.NoError(t, err)
|
||||
|
||||
val, err := qType.Value()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, stringType, val)
|
||||
}
|
||||
|
||||
func TestMimeTypeValid(t *testing.T) {
|
||||
assert.True(t, repository.CleanmimetypeApplicationPdf.Valid())
|
||||
}
|
||||
Reference in New Issue
Block a user