25 lines
583 B
Go
25 lines
583 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
func TestStockJSONUsesTotalOnHandContract(t *testing.T) {
|
|
payload, err := json.Marshal(Stock{TotalOnHand: decimal.RequireFromString("12.5")})
|
|
if err != nil {
|
|
t.Fatalf("marshal stock: %v", err)
|
|
}
|
|
|
|
jsonText := string(payload)
|
|
if !strings.Contains(jsonText, `"total_on_hand":"12.5"`) {
|
|
t.Fatalf("payload %s does not expose total_on_hand", jsonText)
|
|
}
|
|
if strings.Contains(jsonText, "current_stock") {
|
|
t.Fatalf("payload %s still exposes legacy current_stock", jsonText)
|
|
}
|
|
}
|