Compare commits
2 Commits
fix/temp-d
...
update/cha
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c004dd838 | |||
| 1ce63fbdb9 |
@@ -709,6 +709,14 @@ func TestConvertCartLimit(t *testing.T) {
|
|||||||
t.Fatalf("seed card: %v", err)
|
t.Fatalf("seed card: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pin coffee_id=4's price so cart-cap math stays stable across
|
||||||
|
// seed-price changes. The cap test is about (price * quantity)
|
||||||
|
// vs cap, not which coffee or what the menu currently charges.
|
||||||
|
const pinnedPrice = 500
|
||||||
|
if err := db.Model(&models.Coffee{}).Where("id = ?", 4).Update("price", pinnedPrice).Error; err != nil {
|
||||||
|
t.Fatalf("pin coffee price: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
handler := NewCartHandler("", "", tc.capCents)
|
handler := NewCartHandler("", "", tc.capCents)
|
||||||
|
|
||||||
body, _ := json.Marshal(map[string]interface{}{"coffee_id": 4, "quantity": tc.quantity})
|
body, _ := json.Marshal(map[string]interface{}{"coffee_id": 4, "quantity": tc.quantity})
|
||||||
@@ -760,8 +768,8 @@ func TestConvertCartLimit(t *testing.T) {
|
|||||||
if got, _ := resp.Error.Details["limit_cents"].(float64); int(got) != tc.capCents {
|
if got, _ := resp.Error.Details["limit_cents"].(float64); int(got) != tc.capCents {
|
||||||
t.Errorf("limit_cents in details: want %d, got %v", tc.capCents, resp.Error.Details["limit_cents"])
|
t.Errorf("limit_cents in details: want %d, got %v", tc.capCents, resp.Error.Details["limit_cents"])
|
||||||
}
|
}
|
||||||
if got, _ := resp.Error.Details["total_cents"].(float64); int(got) != tc.quantity*500 {
|
if got, _ := resp.Error.Details["total_cents"].(float64); int(got) != tc.quantity*pinnedPrice {
|
||||||
t.Errorf("total_cents in details: want %d, got %v", tc.quantity*500, resp.Error.Details["total_cents"])
|
t.Errorf("total_cents in details: want %d, got %v", tc.quantity*pinnedPrice, resp.Error.Details["total_cents"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
"terminalShop/pkg/models"
|
"terminalShop/pkg/models"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Seed populates the database with initial data
|
// Seed populates the database with initial data
|
||||||
@@ -27,7 +28,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
Ounces: 2,
|
Ounces: 2,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 350, // $3.50
|
Price: 1800, // $18.00
|
||||||
Color: "#8B4513",
|
Color: "#8B4513",
|
||||||
Description: "Bold and intense coffee with a rich crema",
|
Description: "Bold and intense coffee with a rich crema",
|
||||||
},
|
},
|
||||||
@@ -36,7 +37,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
Ounces: 8,
|
Ounces: 8,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 400, // $4.00
|
Price: 2200, // $22.00
|
||||||
Color: "#A0522D",
|
Color: "#A0522D",
|
||||||
Description: "Smooth and balanced espresso diluted with hot water",
|
Description: "Smooth and balanced espresso diluted with hot water",
|
||||||
},
|
},
|
||||||
@@ -45,7 +46,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
Ounces: 6,
|
Ounces: 6,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 450, // $4.50
|
Price: 2200, // $22.00
|
||||||
Color: "#C4A574",
|
Color: "#C4A574",
|
||||||
Description: "Espresso with steamed milk and a thick layer of foam",
|
Description: "Espresso with steamed milk and a thick layer of foam",
|
||||||
},
|
},
|
||||||
@@ -54,7 +55,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Medium Roast",
|
RoastType: "Medium Roast",
|
||||||
Ounces: 12,
|
Ounces: 12,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 500, // $5.00
|
Price: 2500, // $25.00
|
||||||
Color: "#D2B48C",
|
Color: "#D2B48C",
|
||||||
Description: "Creamy espresso with plenty of steamed milk and a touch of foam",
|
Description: "Creamy espresso with plenty of steamed milk and a touch of foam",
|
||||||
},
|
},
|
||||||
@@ -63,7 +64,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
Ounces: 12,
|
Ounces: 12,
|
||||||
BeanType: "Arabica",
|
BeanType: "Arabica",
|
||||||
Price: 550, // $5.50
|
Price: 3000, // $30.00
|
||||||
Color: "#8B4513",
|
Color: "#8B4513",
|
||||||
Description: "Chocolate and espresso combined with steamed milk. Sweet and indulgent.",
|
Description: "Chocolate and espresso combined with steamed milk. Sweet and indulgent.",
|
||||||
},
|
},
|
||||||
@@ -72,7 +73,7 @@ func Seed(db *gorm.DB) error {
|
|||||||
RoastType: "Dark Roast",
|
RoastType: "Dark Roast",
|
||||||
Ounces: 3,
|
Ounces: 3,
|
||||||
BeanType: "Robusta Blend",
|
BeanType: "Robusta Blend",
|
||||||
Price: 425, // $4.25
|
Price: 1800, // $18.00
|
||||||
Color: "#DAA520",
|
Color: "#DAA520",
|
||||||
Description: "Espresso 'marked' with a dollop of foamed milk. Small but mighty, like a tiny caffeinated warrior.",
|
Description: "Espresso 'marked' with a dollop of foamed milk. Small but mighty, like a tiny caffeinated warrior.",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user