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)
| 12947 | // clear every field set by a prior non-zero write, so nothing leaks if |
| 12948 | // someone later introduces merge/patch semantics. |
| 12949 | func 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 |
nothing calls this directly
no test coverage detected