48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package transformer
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"apskel-pos-be/internal/contract"
|
|
"apskel-pos-be/internal/models"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreatePurchaseOrderRequestToModelAllowsMissingDueDate(t *testing.T) {
|
|
ingredientID := uuid.New()
|
|
quantity := 1.0
|
|
unitID := uuid.New()
|
|
|
|
result, err := CreatePurchaseOrderRequestToModel(&contract.CreatePurchaseOrderRequest{
|
|
VendorID: uuid.New(),
|
|
PONumber: "PO-001",
|
|
TransactionDate: "2026-05-29",
|
|
Items: []contract.CreatePurchaseOrderItemRequest{
|
|
{
|
|
IngredientID: &ingredientID,
|
|
Quantity: &quantity,
|
|
UnitID: &unitID,
|
|
Amount: 1000,
|
|
},
|
|
},
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
require.Nil(t, result.DueDate)
|
|
}
|
|
|
|
func TestPurchaseOrderModelResponseToResponseIncludesNullDueDate(t *testing.T) {
|
|
result := PurchaseOrderModelResponseToResponse(&models.PurchaseOrderResponse{
|
|
ID: uuid.New(),
|
|
VendorID: uuid.New(),
|
|
PONumber: "PO-001",
|
|
})
|
|
|
|
payload, err := json.Marshal(result)
|
|
require.NoError(t, err)
|
|
require.Contains(t, string(payload), `"due_date":null`)
|
|
}
|