PPysolate SpineREAD THE CODE · UNDERSTAND THE SYSTEM
课程与章节
源码索引 / CURRENT IMPLEMENTATION

learning/go-patterns/stages/06-bounded/quote_test.go

18 行 · 点击行号可定位;函数链接随声明位置更新,不手填行号。

跳到函数 / 声明
package main

import (
	"context"
	"testing"
)

func TestQuoteBusiness(t *testing.T) {
	s := NewService(Catalog{"book": 2100, "pen": 300, "shipping": 500})
	p, err := s.Quote(context.Background(), "book")
	if err != nil || p.Item != "book" || p.Cents != 2600 {
		t.Fatalf("%+v %v", p, err)
	}
	q, err := s.QuoteMany(context.Background(), []string{"book", "pen"}, 2)
	if err != nil || q[0].Cents != 2600 || q[1].Cents != 800 {
		t.Fatalf("%v %v", q, err)
	}
}