diff --git a/internal/adapter/openai/deps_injection_test.go b/internal/adapter/openai/deps_injection_test.go index 6286c0c..9025ef3 100644 --- a/internal/adapter/openai/deps_injection_test.go +++ b/internal/adapter/openai/deps_injection_test.go @@ -19,6 +19,7 @@ func (m mockOpenAIConfig) ToolcallMode() string { return m.toolMo func (m mockOpenAIConfig) ToolcallEarlyEmitConfidence() string { return m.earlyEmit } func (m mockOpenAIConfig) ResponsesStoreTTLSeconds() int { return m.responsesTTL } func (m mockOpenAIConfig) EmbeddingsProvider() string { return m.embedProv } +func (m mockOpenAIConfig) AutoDeleteSessions() bool { return false } func TestNormalizeOpenAIChatRequestWithConfigInterface(t *testing.T) { cfg := mockOpenAIConfig{ diff --git a/internal/adapter/openai/stream_status_test.go b/internal/adapter/openai/stream_status_test.go index 4d66b46..9bd6ccd 100644 --- a/internal/adapter/openai/stream_status_test.go +++ b/internal/adapter/openai/stream_status_test.go @@ -53,6 +53,10 @@ func (m streamStatusDSStub) CallCompletion(_ context.Context, _ *auth.RequestAut return m.resp, nil } +func (m streamStatusDSStub) DeleteAllSessionsForToken(_ context.Context, _ string) (int, error) { + return 0, nil +} + func makeOpenAISSEHTTPResponse(lines ...string) *http.Response { body := strings.Join(lines, "\n") if !strings.HasSuffix(body, "\n") { diff --git a/internal/admin/handler_accounts_testing_test.go b/internal/admin/handler_accounts_testing_test.go index 4c84fd6..47013c1 100644 --- a/internal/admin/handler_accounts_testing_test.go +++ b/internal/admin/handler_accounts_testing_test.go @@ -9,6 +9,7 @@ import ( "ds2api/internal/auth" "ds2api/internal/config" + "ds2api/internal/deepseek" ) type testingDSMock struct { @@ -38,6 +39,14 @@ func (m *testingDSMock) CallCompletion(_ context.Context, _ *auth.RequestAuth, _ return nil, errors.New("should not call CallCompletion in this test") } +func (m *testingDSMock) DeleteAllSessionsForToken(_ context.Context, _ string) (int, error) { + return 0, nil +} + +func (m *testingDSMock) GetSessionCountForToken(_ context.Context, _ string) (*deepseek.SessionStats, error) { + return &deepseek.SessionStats{Success: true}, nil +} + func TestTestAccount_BatchModeOnlyCreatesSession(t *testing.T) { t.Setenv("DS2API_CONFIG_JSON", `{"accounts":[{"email":"batch@example.com","password":"pwd","token":""}]}`) store := config.LoadStore() diff --git a/internal/deepseek/client_session_delete.go b/internal/deepseek/client_session_delete.go index 2f49fc5..a34a56f 100644 --- a/internal/deepseek/client_session_delete.go +++ b/internal/deepseek/client_session_delete.go @@ -107,7 +107,7 @@ func (c *Client) DeleteSessionForToken(ctx context.Context, token string, sessio if status != http.StatusOK || code != 0 { msg, _ := resp["msg"].(string) result.ErrorMessage = fmt.Sprintf("request failed: status=%d, code=%d, msg=%s", status, code, msg) - return result, fmt.Errorf(result.ErrorMessage) + return result, errors.New(result.ErrorMessage) } result.Success = true