MCPcopy Index your code
hub / github.com/coder/coder / TestUserChatCompactionThresholds

Function TestUserChatCompactionThresholds

coderd/exp_chats_test.go:13365–13508  ·  view source on GitHub ↗

nolint:tparallel // subtests share state via client, firstUser, modelConfig

(t *testing.T)

Source from the content-addressed store, hash-verified

13363
13364//nolint:tparallel // subtests share state via client, firstUser, modelConfig
13365func TestUserChatCompactionThresholds(t *testing.T) {
13366 t.Parallel()
13367
13368 client, _ := newChatClientWithDatabase(t)
13369 firstUser := coderdtest.CreateFirstUser(t, client.Client)
13370 modelConfig := createChatModelConfig(t, client)
13371
13372 t.Run("EmptyByDefault", func(t *testing.T) { //nolint:paralleltest // subtests share parent state
13373 ctx := testutil.Context(t, testutil.WaitLong)
13374
13375 thresholds, err := client.GetUserChatCompactionThresholds(ctx)
13376 require.NoError(t, err)
13377 require.Empty(t, thresholds.Thresholds)
13378 })
13379
13380 t.Run("PutAndGet", func(t *testing.T) { //nolint:paralleltest // subtests share parent state
13381 ctx := testutil.Context(t, testutil.WaitLong)
13382
13383 override, err := client.UpdateUserChatCompactionThreshold(ctx, modelConfig.ID, codersdk.UpdateUserChatCompactionThresholdRequest{
13384 ThresholdPercent: 75,
13385 })
13386 require.NoError(t, err)
13387 require.Equal(t, modelConfig.ID, override.ModelConfigID)
13388 require.EqualValues(t, 75, override.ThresholdPercent)
13389
13390 thresholds, err := client.GetUserChatCompactionThresholds(ctx)
13391 require.NoError(t, err)
13392 require.Len(t, thresholds.Thresholds, 1)
13393 require.Equal(t, modelConfig.ID, thresholds.Thresholds[0].ModelConfigID)
13394 require.EqualValues(t, 75, thresholds.Thresholds[0].ThresholdPercent)
13395 })
13396
13397 t.Run("UpsertChangesValue", func(t *testing.T) { //nolint:paralleltest // subtests share parent state
13398 ctx := testutil.Context(t, testutil.WaitLong)
13399
13400 _, err := client.UpdateUserChatCompactionThreshold(ctx, modelConfig.ID, codersdk.UpdateUserChatCompactionThresholdRequest{
13401 ThresholdPercent: 50,
13402 })
13403 require.NoError(t, err)
13404
13405 override, err := client.UpdateUserChatCompactionThreshold(ctx, modelConfig.ID, codersdk.UpdateUserChatCompactionThresholdRequest{
13406 ThresholdPercent: 75,
13407 })
13408 require.NoError(t, err)
13409 require.EqualValues(t, 75, override.ThresholdPercent)
13410
13411 thresholds, err := client.GetUserChatCompactionThresholds(ctx)
13412 require.NoError(t, err)
13413 require.Len(t, thresholds.Thresholds, 1)
13414 require.EqualValues(t, 75, thresholds.Thresholds[0].ThresholdPercent)
13415 })
13416
13417 t.Run("BoundaryValues", func(t *testing.T) { //nolint:paralleltest // subtests share parent state
13418 ctx := testutil.Context(t, testutil.WaitLong)
13419
13420 override, err := client.UpdateUserChatCompactionThreshold(ctx, modelConfig.ID, codersdk.UpdateUserChatCompactionThresholdRequest{
13421 ThresholdPercent: 0,
13422 })

Callers

nothing calls this directly

Calls 15

CreateFirstUserFunction · 0.92
ContextFunction · 0.92
CreateAnotherUserFunction · 0.92
NewExperimentalClientFunction · 0.92
requireSDKErrorFunction · 0.85
createChatModelConfigFunction · 0.70
RunMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected