newActiveTestServer creates a chatd server that actively polls for and processes pending chats. Use this instead of newTestServer when the test needs the chat loop to actually run. Optional config overrides are applied after the defaults.
( t *testing.T, db database.Store, ps dbpubsub.Pubsub, overrides ...func(*chatd.Config), )
| 5894 | // the test needs the chat loop to actually run. Optional config |
| 5895 | // overrides are applied after the defaults. |
| 5896 | func newActiveTestServer( |
| 5897 | t *testing.T, |
| 5898 | db database.Store, |
| 5899 | ps dbpubsub.Pubsub, |
| 5900 | overrides ...func(*chatd.Config), |
| 5901 | ) *chatd.Server { |
| 5902 | t.Helper() |
| 5903 | |
| 5904 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 5905 | cfg := chatd.Config{ |
| 5906 | Logger: logger, |
| 5907 | Database: db, |
| 5908 | ReplicaID: uuid.New(), |
| 5909 | Pubsub: ps, |
| 5910 | PendingChatAcquireInterval: 10 * time.Millisecond, |
| 5911 | InFlightChatStaleAfter: testutil.WaitSuperLong, |
| 5912 | } |
| 5913 | for _, o := range overrides { |
| 5914 | o(&cfg) |
| 5915 | } |
| 5916 | server := chatd.New(cfg) |
| 5917 | server.Start() |
| 5918 | t.Cleanup(func() { |
| 5919 | require.NoError(t, server.Close()) |
| 5920 | }) |
| 5921 | return server |
| 5922 | } |
| 5923 | |
| 5924 | func TestProposeChatTitle_DebugRun(t *testing.T) { |
| 5925 | t.Parallel() |
no test coverage detected