(t *testing.T)
| 25 | ) |
| 26 | |
| 27 | func 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 | |
| 55 | func TestHttpTubeSinkTubeNotImplement(t *testing.T) { |
| 56 | f := NewHttpTubeFactory(context.Background()) |
nothing calls this directly
no test coverage detected