stub で提供可 • weavertest.Fake テストのサポート機能 import ( ... "github.com/ServiceWeaver/weaver" "github.com/ServiceWeaver/weaver/weavertest" ) type fakeClock struct { now int64 } func (f *fakeClock) Now(context.Context) (int64, error) { return f.now, nil } func TestClock(t *testing.T) { for _, runner := range weavertest.AllRunners() { fake := &fakeClock{100} runner.Fakes = append(runner.Fakes, weavertest.Fake[Clock](fake)) runner.Test(t, func(t *testing.T, clock Clock) { now, err := clock.UnixMicro(context.Background()) if err != nil { t.Fatal(err) } if now != 100 { t.Fatalf("bad time: got %d, want %d", now, 100) } }) } } ...