MCPcopy Create free account
hub / github.com/ddev/ddev / TestIsCodespaces

Function TestIsCodespaces

pkg/nodeps/utils_test.go:238–253  ·  view source on GitHub ↗

TestIsCodespaces tests IsCodespaces function

(t *testing.T)

Source from the content-addressed store, hash-verified

236
237// TestIsCodespaces tests IsCodespaces function
238func TestIsCodespaces(t *testing.T) {
239 // Test that the function returns a boolean without error
240 result := nodeps.IsCodespaces()
241 require.IsType(t, false, result)
242
243 // Test the logic based on current environment
244 // IsCodespaces should return true only if:
245 // 1. DDEV_PRETEND_CODESPACES=true (for testing purposes), OR
246 // 2. Running on Linux AND CODESPACES=true
247 pretendCodespaces := nodeps.IsEnvTrue("DDEV_PRETEND_CODESPACES")
248 codespacesEnv := os.Getenv("CODESPACES") == "true"
249 isLinux := runtime.GOOS == "linux"
250
251 expectedResult := pretendCodespaces || (isLinux && codespacesEnv)
252 require.Equal(t, expectedResult, result)
253}
254
255// TestGetWSLDistro tests GetWSLDistro function
256func TestGetWSLDistro(t *testing.T) {

Callers

nothing calls this directly

Calls 2

IsCodespacesFunction · 0.92
IsEnvTrueFunction · 0.92

Tested by

no test coverage detected