(t *testing.T)
| 4033 | } |
| 4034 | |
| 4035 | func 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 |
nothing calls this directly
no test coverage detected