MCPcopy Create free account
hub / github.com/coder/coder / TestSnapshotChanged

Function TestSnapshotChanged

agent/x/agentmcp/reload_internal_test.go:61–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestSnapshotChanged(t *testing.T) {
62 t.Parallel()
63
64 type testCase struct {
65 name string
66 setup func(t *testing.T, dir string) []string
67 mutate func(t *testing.T, dir string)
68 checkPaths func(t *testing.T, dir string, initialPaths []string) []string
69 want bool
70 }
71
72 cases := []testCase{
73 {
74 name: "UnchangedFiles",
75 setup: func(t *testing.T, dir string) []string {
76 t.Helper()
77 _, entry := fakeMCPServerConfig(t, "srv")
78 configPath := writeMCPConfig(t, dir, map[string]mcpServerEntry{"srv": entry})
79 return []string{configPath}
80 },
81 want: false,
82 },
83 {
84 name: "ContentChange",
85 setup: func(t *testing.T, dir string) []string {
86 t.Helper()
87 _, entry := fakeMCPServerConfig(t, "srv")
88 configPath := writeMCPConfig(t, dir, map[string]mcpServerEntry{"srv": entry})
89 return []string{configPath}
90 },
91 mutate: func(t *testing.T, dir string) {
92 t.Helper()
93 _, entry2 := fakeMCPServerConfig(t, "srv2")
94 writeMCPConfig(t, dir, map[string]mcpServerEntry{"srv2": entry2})
95 },
96 want: true,
97 },
98 {
99 name: "FileBecomesMissing",
100 setup: func(t *testing.T, dir string) []string {
101 t.Helper()
102 _, entry := fakeMCPServerConfig(t, "srv")
103 configPath := writeMCPConfig(t, dir, map[string]mcpServerEntry{"srv": entry})
104 return []string{configPath}
105 },
106 mutate: func(t *testing.T, dir string) {
107 t.Helper()
108 require.NoError(t, os.Remove(filepath.Join(dir, ".mcp.json")))
109 },
110 want: true,
111 },
112 {
113 name: "FileAppears",
114 setup: func(t *testing.T, dir string) []string {
115 t.Helper()
116 return []string{filepath.Join(dir, ".mcp.json")}
117 },
118 mutate: func(t *testing.T, dir string) {

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
ReloadMethod · 0.95
SnapshotChangedMethod · 0.95
ContextFunction · 0.92
fakeMCPServerConfigFunction · 0.85
writeMCPConfigFunction · 0.85
NewManagerFunction · 0.70
HelperMethod · 0.65
RemoveMethod · 0.65
RunMethod · 0.65
TempDirMethod · 0.65
CleanupMethod · 0.65

Tested by

no test coverage detected