MCPcopy Create free account
hub / github.com/coder/coder / TestShouldPublishFinishedChatState

Function TestShouldPublishFinishedChatState

coderd/x/chatd/chatd_internal_test.go:4035–4067  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4033}
4034
4035func TestShouldPublishFinishedChatState(t *testing.T) {
4036 t.Parallel()
4037
4038 ctx := testutil.Context(t, testutil.WaitShort)
4039 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
4040 ctrl := gomock.NewController(t)
4041 db := dbmock.NewMockStore(ctrl)
4042 chatID := uuid.New()
4043 workerID := uuid.New()
4044
4045 server := &Server{db: db}
4046 updatedChat := database.Chat{
4047 ID: chatID,
4048 Status: database.ChatStatusWaiting,
4049 WorkerID: uuid.NullUUID{},
4050 }
4051
4052 db.EXPECT().GetChatByID(gomock.Any(), chatID).Return(database.Chat{
4053 ID: chatID,
4054 Status: database.ChatStatusWaiting,
4055 WorkerID: uuid.NullUUID{},
4056 }, nil)
4057
4058 require.True(t, server.shouldPublishFinishedChatState(ctx, logger, updatedChat))
4059
4060 db.EXPECT().GetChatByID(gomock.Any(), chatID).Return(database.Chat{
4061 ID: chatID,
4062 Status: database.ChatStatusRunning,
4063 WorkerID: uuid.NullUUID{UUID: workerID, Valid: true},
4064 }, nil)
4065
4066 require.False(t, server.shouldPublishFinishedChatState(ctx, logger, updatedChat))
4067}
4068
4069// TestShouldPublishFinishedChatState_DBErrorPublishes pins the
4070// deliberate fail-open behavior when the re-read query errors: we

Callers

nothing calls this directly

Calls 6

EXPECTMethod · 0.95
ContextFunction · 0.92
NewMockStoreFunction · 0.92
NewMethod · 0.65
GetChatByIDMethod · 0.65

Tested by

no test coverage detected