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

Function TestChatAdvisorConfig_ClampsNegativeStoredValues

coderd/exp_chats_test.go:13007–13029  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13005}
13006
13007func TestChatAdvisorConfig_ClampsNegativeStoredValues(t *testing.T) {
13008 t.Parallel()
13009
13010 ctx := testutil.Context(t, testutil.WaitLong)
13011 adminClient, db := newChatClientWithDatabase(t)
13012 coderdtest.CreateFirstUser(t, adminClient.Client)
13013
13014 stored := `{"enabled":true,"max_uses_per_run":-3,"max_output_tokens":-99}`
13015 err := db.UpsertChatAdvisorConfig(dbauthz.AsSystemRestricted(ctx), stored)
13016 require.NoError(t, err)
13017
13018 resp, err := adminClient.GetChatAdvisorConfig(ctx)
13019 require.NoError(t, err)
13020 require.Equal(t, codersdk.AdvisorConfig{
13021 Enabled: true,
13022 MaxUsesPerRun: 0,
13023 MaxOutputTokens: 0,
13024 }, resp)
13025
13026 raw, err := db.GetChatAdvisorConfig(dbauthz.AsSystemRestricted(ctx))
13027 require.NoError(t, err)
13028 require.JSONEq(t, stored, raw)
13029}
13030
13031func TestChatAdvisorConfig_IgnoresLegacyReasoningEffort(t *testing.T) {
13032 t.Parallel()

Callers

nothing calls this directly

Calls 7

ContextFunction · 0.92
CreateFirstUserFunction · 0.92
AsSystemRestrictedFunction · 0.92
GetChatAdvisorConfigMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected