MCPcopy Create free account
hub / github.com/google/go-cloud / TestHandleRequest

Function TestHandleRequest

samples/order/processor_test.go:31–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestHandleRequest(t *testing.T) {
32 f, p, cleanup, err := setup(testConfig("ProcessorRun"))
33 if err != nil {
34 t.Fatal(err)
35 }
36 defer cleanup()
37
38 ctx := context.Background()
39 req := &OrderRequest{ID: "x"}
40 bytes, err := json.Marshal(req)
41 if err != nil {
42 t.Fatal(err)
43 }
44 if err := f.requestTopic.Send(ctx, &pubsub.Message{Body: bytes}); err != nil {
45 t.Fatal(err)
46 }
47 if err := p.handleRequest(ctx); err != nil {
48 t.Fatal(err)
49 }
50 // Just verify that there is an order "x" in the collection.
51 order := &Order{ID: "x"}
52 if err := p.coll.Get(ctx, order); err != nil {
53 t.Fatal(err)
54 }
55}
56
57func TestProcessOrder(t *testing.T) {
58 _, p, cleanup, err := setup(testConfig("ProcessOrder"))

Callers

nothing calls this directly

Calls 5

testConfigFunction · 0.85
SendMethod · 0.80
handleRequestMethod · 0.80
setupFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected