예제 #1
0
파일: api.go 프로젝트: duskhacker/cqrsnu
func OpenTab(c *gin.Context) {
	json := struct {
		WaitStaff string `json:"waitstaff" binding:"required"`
	}{}

	if err := c.BindJSON(&json); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}

	openTabCmd := cafe.NewOpenTab(1, json.WaitStaff)
	cafe.Send(cafe.OpenTabTopic, openTabCmd)

	c.JSON(http.StatusAccepted, gin.H{"tabID": openTabCmd.ID.String()})
}
예제 #2
0
var pf = fmt.Printf

var testConsumers []*nsq.Consumer

var _ = Describe("Chef TODOs", func() {

	var (
		openTabCmd cafe.OpenTab
		tabID      uuid.UUID
		drinks     []cafe.OrderedItem
		food       []cafe.OrderedItem
	)

	BeforeEach(func() {
		openTabCmd = cafe.NewOpenTab(1, "Kinessa")
		tabID = openTabCmd.ID

		drinks = []cafe.OrderedItem{}
		drinks = append(drinks, cafe.NewOrderedItem(1, "Patron", true, 5.00))
		drinks = append(drinks, cafe.NewOrderedItem(2, "Scotch", true, 3.50))

		food = []cafe.OrderedItem{}
		food = append(food, cafe.NewOrderedItem(1, "Steak", false, 15.00))
		food = append(food, cafe.NewOrderedItem(2, "Burger", false, 8.00))
	})

	AfterEach(func() {
		stopAllTestConsumers()
	})