MCPcopy Create free account
hub / github.com/github/gh-aw / TestIsRunningAsMCPServer

Function TestIsRunningAsMCPServer

pkg/cli/update_check_test.go:126–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestIsRunningAsMCPServer(t *testing.T) {
127 // Save original environment
128 origMCP := os.Getenv("GH_AW_MCP_SERVER")
129 defer func() {
130 os.Setenv("GH_AW_MCP_SERVER", origMCP)
131 }()
132
133 tests := []struct {
134 name string
135 mcpEnv string
136 expected bool
137 }{
138 {
139 name: "not in MCP server mode",
140 mcpEnv: "",
141 expected: false,
142 },
143 {
144 name: "in MCP server mode",
145 mcpEnv: "true",
146 expected: true,
147 },
148 }
149
150 for _, tt := range tests {
151 t.Run(tt.name, func(t *testing.T) {
152 os.Setenv("GH_AW_MCP_SERVER", tt.mcpEnv)
153 result := isRunningAsMCPServer()
154 if result != tt.expected {
155 t.Errorf("isRunningAsMCPServer() = %v, want %v", result, tt.expected)
156 }
157 })
158 }
159}
160
161func TestGetLastCheckFilePath(t *testing.T) {
162 path := getLastCheckFilePath()

Callers

nothing calls this directly

Calls 5

isRunningAsMCPServerFunction · 0.85
GetenvMethod · 0.80
SetenvMethod · 0.80
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected