hiling_go/db/sqlc/test/locations_test.go
2024-02-06 11:55:25 +07:00

37 lines
919 B
Go

package db_test
import (
"context"
"testing"
db "git.nochill.in/nochill/hiling_go/db/sqlc"
"git.nochill.in/nochill/hiling_go/util"
"github.com/jackc/pgx/v5/pgtype"
"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: pgtype.Text{Valid: true, String: util.RandomString(10)},
}
_, err := testQueries.CreateLocation(context.Background(), arg)
require.NoError(t, err)
}