2023-09-13 21:42:31 +07:00
|
|
|
package db_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
db "git.nochill.in/nochill/hiling_go/db/sqlc"
|
|
|
|
"git.nochill.in/nochill/hiling_go/util"
|
2024-02-06 11:55:25 +07:00
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
2023-09-13 21:42:31 +07:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetLocationsList(t *testing.T) {
|
2023-09-14 13:49:03 +07:00
|
|
|
locations, err := testQueries.GetListLocations(context.Background())
|
2023-09-13 21:42:31 +07:00
|
|
|
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,
|
2024-02-06 11:55:25 +07:00
|
|
|
GoogleMapsLink: pgtype.Text{Valid: true, String: util.RandomString(10)},
|
2023-09-13 21:42:31 +07:00
|
|
|
}
|
|
|
|
|
2023-10-03 14:56:57 +07:00
|
|
|
_, err := testQueries.CreateLocation(context.Background(), arg)
|
2023-09-13 21:42:31 +07:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|