charm icon indicating copy to clipboard operation
charm copied to clipboard

Add basic charm serve integration tests

Open rubiojr opened this issue 2 years ago • 3 comments

Tests for https://github.com/charmbracelet/charm/pull/36 that was merged recently.

Some notes:

Introduced the testify dependency. Happy to remove it if you prefer to test without it.

The test waits for the server to start serving requests so we can test the output, database path, etc. I did it testing we can actually establish a connection to the HTTP port which also works as a test, but has the potential of introducing test flakiness, given we wait for a fixed amount of time for the server to start. Unlikely since 5 secs should be plenty for the server to start, but the potential is there.

cc @muesli @toby

rubiojr avatar Dec 19 '21 18:12 rubiojr

@rubiojr Just a quick heads up: we love all your PRs! testify as a dependency for the tests is absolutely fine. I'll fix the goreleaser workflow failing for PRs asap.

muesli avatar Dec 19 '21 18:12 muesli

Unlikely since 5 secs should be plenty for the server to start, but the potential is there.

Speaking of which... I had to bump the wait time in 1b273c1ce0ee763c976e9233233ab43e9532907a because GitHub folks :grimacing: run actions in overwhelmed hosts that are slow enough to break it.

rubiojr avatar Dec 19 '21 19:12 rubiojr

Starting/stopping the servers programmatically from tests required a larger surgery than expected, but hopefully opens the door to easier integration tests, graceful servers shutdowns via signals etc.

514e1be introduces context for HTTP and SSH servers so we can stop them programmatically using a cancelable context, which is useful for the tests I'm adding here.

rubiojr avatar Dec 20 '21 09:12 rubiojr

Spring cleaning. Much has changed since I opened this,so it's probably largely irrelevant at this point. Please let me know and re-open if you'd rather keep this open :heart:.

rubiojr avatar Sep 14 '22 13:09 rubiojr