2023-03-05 23:35:41 +07:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 18:52:37 +07:00
|
|
|
"git.nochill.in/nochill/naice_pos/util"
|
2023-03-05 23:35:41 +07:00
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func createRandomSupplier(t *testing.T) (Supplier, CreateSuppliersParams) {
|
|
|
|
arg := CreateSuppliersParams{
|
2023-03-21 13:15:14 +07:00
|
|
|
MerchantID: uuid.MustParse("04a1b0a7-69b4-41da-a053-2f6b95c93195"),
|
2023-03-05 23:35:41 +07:00
|
|
|
Name: util.RandomString(10),
|
|
|
|
}
|
|
|
|
|
|
|
|
supplier, err := testQueries.CreateSuppliers(context.Background(), arg)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return supplier, arg
|
|
|
|
|
|
|
|
}
|
|
|
|
func TestCreateSupplier(t *testing.T) {
|
|
|
|
supplier, arg := createRandomSupplier(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)
|
|
|
|
|
|
|
|
}
|