2023-03-22 12:06:09 +07:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"git.nochill.in/nochill/naice_pos/util"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func createRandomCustomer(t *testing.T) (Customer, CreateCustomersParams) {
|
|
|
|
arg := CreateCustomersParams{
|
2023-03-22 13:40:18 +07:00
|
|
|
MerchantID: uuid.MustParse("7e525a4b-4208-4f05-99a1-a75df475dd9b"),
|
2023-03-22 12:06:09 +07:00
|
|
|
Name: util.RandomString(10),
|
|
|
|
}
|
|
|
|
|
|
|
|
customer, err := testQueries.CreateCustomers(context.Background(), arg)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return customer, arg
|
|
|
|
|
|
|
|
}
|
|
|
|
func TestCreateCustomer(t *testing.T) {
|
|
|
|
supplier, arg := createRandomCustomer(t)
|
|
|
|
|
|
|
|
require.Equal(t, arg.Name, supplier.Name)
|
|
|
|
require.Equal(t, arg.MerchantID, supplier.MerchantID)
|
|
|
|
|
|
|
|
require.NotZero(t, supplier.ID)
|
|
|
|
require.NotZero(t, supplier.CreatedAt)
|
|
|
|
require.NotZero(t, supplier.UpdatedAt)
|
|
|
|
|
|
|
|
}
|