MCPcopy Create free account
hub / github.com/WhyWhatHow/jenv / TestQuerySystemEnvironmentVariable

Function TestQuerySystemEnvironmentVariable

src/internal/env/env_unix_test.go:182–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

180}
181
182func TestQuerySystemEnvironmentVariable(t *testing.T) {
183 // Test with a known environment variable
184 key := "PATH"
185 value, err := QuerySystemEnvironmentVariable(key)
186 if err != nil {
187 t.Errorf("QuerySystemEnvironmentVariable failed: %v", err)
188 }
189
190 if value == "" {
191 t.Errorf("Expected non-empty PATH, got empty string")
192 }
193
194 // Test with non-existent variable
195 nonExistentKey := "JENV_TEST_NON_EXISTENT_VAR"
196 value, err = QuerySystemEnvironmentVariable(nonExistentKey)
197 if err != nil {
198 // This is expected for non-existent variables
199 t.Logf("Expected error for non-existent variable: %v", err)
200 }
201
202 if value != "" {
203 t.Errorf("Expected empty value for non-existent variable, got: %s", value)
204 }
205}
206
207func TestUpdateShellConfigFile(t *testing.T) {
208 // Create a temporary file

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected