MCPcopy Index your code
hub / github.com/docker/docker-agent / runRuntimeContract

Function runRuntimeContract

pkg/runtime/contract_test.go:21–129  ·  view source on GitHub ↗

runRuntimeContract exercises every non-streaming method on the Runtime interface. It runs against any factory so that LocalRuntime and (in a future commit) RemoteRuntime can be checked against the same expectations. Streaming methods (RunStream, Run, Summarize) are exercised by the type-specific te

(t *testing.T, newRT func(t *testing.T) Runtime)

Source from the content-addressed store, hash-verified

19// Streaming methods (RunStream, Run, Summarize) are exercised by the
20// type-specific test files because they need real models or providers.
21func runRuntimeContract(t *testing.T, newRT func(t *testing.T) Runtime) {
22 t.Helper()
23
24 t.Run("CurrentAgentName not empty", func(t *testing.T) {
25 rt := newRT(t)
26 t.Cleanup(func() { _ = rt.Close() })
27 assert.NotEmpty(t, rt.CurrentAgentName(t.Context()))
28 })
29
30 t.Run("CurrentAgentInfo carries the current name", func(t *testing.T) {
31 rt := newRT(t)
32 t.Cleanup(func() { _ = rt.Close() })
33 info := rt.CurrentAgentInfo(t.Context())
34 assert.Equal(t, rt.CurrentAgentName(t.Context()), info.Name)
35 })
36
37 t.Run("SetCurrentAgent rejects unknown agents", func(t *testing.T) {
38 rt := newRT(t)
39 t.Cleanup(func() { _ = rt.Close() })
40 err := rt.SetCurrentAgent(t.Context(), "nonexistent-agent")
41 assert.Error(t, err)
42 })
43
44 t.Run("CurrentAgentTools returns slice or ErrUnsupported", func(t *testing.T) {
45 rt := newRT(t)
46 t.Cleanup(func() { _ = rt.Close() })
47 _, err := rt.CurrentAgentTools(t.Context())
48 if err != nil {
49 assert.ErrorIs(t, err, ErrUnsupported, "unexpected error type: %v", err)
50 }
51 })
52
53 t.Run("CurrentAgentToolsetStatuses does not panic", func(t *testing.T) {
54 rt := newRT(t)
55 t.Cleanup(func() { _ = rt.Close() })
56 _ = rt.CurrentAgentToolsetStatuses()
57 })
58
59 t.Run("RestartToolset on unknown name returns error", func(t *testing.T) {
60 rt := newRT(t)
61 t.Cleanup(func() { _ = rt.Close() })
62 err := rt.RestartToolset(t.Context(), "nonexistent-toolset")
63 assert.Error(t, err)
64 })
65
66 t.Run("CurrentMCPPrompts returns a non-nil map", func(t *testing.T) {
67 rt := newRT(t)
68 t.Cleanup(func() { _ = rt.Close() })
69 prompts := rt.CurrentMCPPrompts(t.Context())
70 assert.NotNil(t, prompts)
71 })
72
73 t.Run("ExecuteMCPPrompt for unknown prompt returns error", func(t *testing.T) {
74 rt := newRT(t)
75 t.Cleanup(func() { _ = rt.Close() })
76 _, err := rt.ExecuteMCPPrompt(t.Context(), "nonexistent-prompt", nil)
77 assert.Error(t, err)
78 })

Callers 2

Calls 15

ResumeApproveFunction · 0.85
ContextMethod · 0.80
RunMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
CurrentAgentNameMethod · 0.65
CurrentAgentInfoMethod · 0.65
SetCurrentAgentMethod · 0.65
CurrentAgentToolsMethod · 0.65
RestartToolsetMethod · 0.65
CurrentMCPPromptsMethod · 0.65

Tested by

no test coverage detected