hiling_go/db/sqlc/test/locations_test.go

37 lines
919 B
Go
Raw Normal View History

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"
"github.com/stretchr/testify/require"
)
func TestGetLocationsList(t *testing.T) {
2023-09-14 13:49:03 +07:00
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,
2024-02-06 11:55:25 +07:00
GoogleMapsLink: pgtype.Text{Valid: true, String: util.RandomString(10)},
}
2023-10-03 14:56:57 +07:00
_, err := testQueries.CreateLocation(context.Background(), arg)
require.NoError(t, err)
}