37 lines
901 B
Go
37 lines
901 B
Go
package db_test
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"testing"
|
|
|
|
db "git.nochill.in/nochill/hiling_go/db/sqlc"
|
|
"git.nochill.in/nochill/hiling_go/util"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetLocationsList(t *testing.T) {
|
|
locations, err := testQueries.GetListLocations(context.Background())
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, locations)
|
|
}
|
|
|
|
func TestGetLocation(t *testing.T) {
|
|
location, err := testQueries.GetLocation(context.Background(), 1)
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, location)
|
|
}
|
|
|
|
func TestCreateLocation(t *testing.T) {
|
|
arg := db.CreateLocationParams{
|
|
Address: util.RandomString(12),
|
|
Name: util.RandomString(10),
|
|
SubmittedBy: 1,
|
|
RegencyID: 1305,
|
|
GoogleMapsLink: sql.NullString{Valid: true, String: util.RandomString(10)},
|
|
}
|
|
|
|
err := testQueries.CreateLocation(context.Background(), arg)
|
|
require.NoError(t, err)
|
|
}
|