MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / TestHttpTubeHandleRecord

Function TestHttpTubeHandleRecord

fs/contube/http_test.go:27–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestHttpTubeHandleRecord(t *testing.T) {
28 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
29 f := NewHttpTubeFactory(ctx)
30
31 endpoint := "test"
32 err := f.Handle(ctx, "test", NewRecordImpl([]byte("test"), nil))
33 assert.ErrorIs(t, err, ErrEndpointNotFound)
34
35 config := make(ConfigMap)
36 config[EndpointKey] = endpoint
37 source, err := f.NewSourceTube(ctx, config)
38 assert.NoError(t, err)
39 _, err = f.NewSourceTube(ctx, config)
40 assert.ErrorIs(t, err, ErrorEndpointAlreadyExists)
41
42 err = f.Handle(ctx, endpoint, NewRecordImpl([]byte("test"), nil))
43 assert.Nil(t, err)
44
45 record := <-source
46 assert.Equal(t, "test", string(record.GetPayload()))
47
48 cancel()
49
50 assert.Nil(t, <-source)
51 err = f.Handle(ctx, endpoint, NewRecordImpl([]byte("test"), nil))
52 assert.Error(t, err, ErrEndpointNotFound)
53}
54
55func TestHttpTubeSinkTubeNotImplement(t *testing.T) {
56 f := NewHttpTubeFactory(context.Background())

Callers

nothing calls this directly

Calls 6

HandleMethod · 0.95
NewSourceTubeMethod · 0.95
NewHttpTubeFactoryFunction · 0.85
NewRecordImplFunction · 0.85
ErrorMethod · 0.80
GetPayloadMethod · 0.65

Tested by

no test coverage detected