Files
David Gageot 0a87da1f97 refactor: thread context through DB and test helper setup
Thread context through sqlite/session/RAG/memory DB setup so constructors and migrations no longer mint fresh roots. Fake proxy cleanup and askpass connection handling now use context providers derived from their startup context. LocalRuntime stores a context provider for tool-change refresh callbacks.

The remaining suppressions are intentionally detached event hooks/MCP supervisor callbacks or compatibility fallbacks.
2026-06-29 10:17:44 +02:00

56 lines
1.2 KiB
Go

package e2e_test
import (
"context"
"net/http/httptest"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/dnaeon/go-vcr.v4/pkg/recorder"
"github.com/docker/docker-agent/pkg/config"
"github.com/docker/docker-agent/pkg/environment"
"github.com/docker/docker-agent/pkg/fake"
)
func startRecordingAIProxy(t *testing.T) (*httptest.Server, *config.RuntimeConfig) {
t.Helper()
cassettePath := filepath.Join("testdata", "cassettes", t.Name())
// Create a matcher that fails the test on error
matcher := fake.DefaultMatcher(func(err error) {
require.NoError(t, err)
})
proxyURL, cleanup, err := fake.StartProxyWithOptions(t.Context(),
cassettePath,
recorder.ModeRecordOnce,
matcher,
fake.APIKeyHeaderUpdater,
nil,
)
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, cleanup())
})
return &httptest.Server{URL: proxyURL}, &config.RuntimeConfig{
Config: config.Config{
ModelsGateway: proxyURL,
},
EnvProviderForTests: &testEnvProvider{
environment.DockerDesktopTokenEnv: "DUMMY",
},
}
}
type testEnvProvider map[string]string
func (p *testEnvProvider) Get(_ context.Context, name string) (string, bool) {
val, found := (*p)[name]
return val, found
}