hiling_go/db/sqlc/test/locations_test.go

37 lines
904 B
Go
Raw Normal View History

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) {
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,
GoogleMapsLink: sql.NullString{Valid: true, String: util.RandomString(10)},
}
2023-10-03 14:56:57 +07:00
_, err := testQueries.CreateLocation(context.Background(), arg)
require.NoError(t, err)
}