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

Function TestChatAdvisorConfig_OverwriteClearsPreviousValues

coderd/exp_chats_test.go:12949–12974  ·  view source on GitHub ↗

TestChatAdvisorConfig_OverwriteClearsPreviousValues pins PUT to full-replace semantics. A second write with zero-valued fields must clear every field set by a prior non-zero write, so nothing leaks if someone later introduces merge/patch semantics.

(t *testing.T)

Source from the content-addressed store, hash-verified

12947// clear every field set by a prior non-zero write, so nothing leaks if
12948// someone later introduces merge/patch semantics.
12949func TestChatAdvisorConfig_OverwriteClearsPreviousValues(t *testing.T) {
12950 t.Parallel()
12951
12952 ctx := testutil.Context(t, testutil.WaitLong)
12953 adminClient := newChatClient(t)
12954 coderdtest.CreateFirstUser(t, adminClient.Client)
12955
12956 modelConfig := createChatModelConfig(t, adminClient)
12957
12958 rich := codersdk.AdvisorConfig{
12959 Enabled: true,
12960 MaxUsesPerRun: 5,
12961 MaxOutputTokens: 1024,
12962 ModelConfigID: modelConfig.ID,
12963 }
12964 err := adminClient.UpdateChatAdvisorConfig(ctx, rich)
12965 require.NoError(t, err)
12966
12967 sparse := codersdk.AdvisorConfig{Enabled: true}
12968 err = adminClient.UpdateChatAdvisorConfig(ctx, sparse)
12969 require.NoError(t, err)
12970
12971 resp, err := adminClient.GetChatAdvisorConfig(ctx)
12972 require.NoError(t, err)
12973 require.Equal(t, sparse, resp)
12974}
12975
12976// TestChatAdvisorConfig_CanBeDisabledAfterEnabled pins the feature
12977// gate's "off" path. The downstream runtime gates the advisor tool and

Callers

nothing calls this directly

Calls 7

ContextFunction · 0.92
CreateFirstUserFunction · 0.92
newChatClientFunction · 0.70
createChatModelConfigFunction · 0.70
GetChatAdvisorConfigMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected