sdk-go
sdk-go copied to clipboard
Samples Don't Have Tests
There are lots of samples for this SDK, but there are no tests.
I can't use most of these samples as there are no tests.
https://github.com/cloudevents/sdk-go/tree/master/samples/http
For example, a simple receiver: https://github.com/cloudevents/sdk-go/blob/master/samples/http/receiver/main.go
I'd expect that we have tests for at least a few of the samples.
Is there any sample that has a test that can be used as a showcase example?
there are a lot of tests that leverage the sdk, look in the https://github.com/cloudevents/sdk-go/tree/master/test/integration dir.
The examples are meant to be examples of client code. to make them testable would also make them more complex and not readable imh.
Though, we did want to look at using golang's Example: https://blog.golang.org/examples
It is a little tricky to show the more interesting things in the SDK like auto-inject time or id, because the end result is not known at the time of writing (it is dynamic).
We are still interested in having a subset of the samples as Example type tests.
For the examples in the docs, there is an open issue #153
It's good seeing the tests/integration folder.
Usually tests are right next to the code though and postfixed with _test.go right? I'd imagine basic samples to have tests.
For the integration folder, I'd imagine a much much shorter test for a very basic HTTP receiver: https://github.com/cloudevents/sdk-go/blob/master/test/integration/http/receiver.go
The test you link confirms the shape on the wire as well as what the sender sent and what the receiver received, so there is some setup.