-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil_test.go
More file actions
49 lines (40 loc) · 1.2 KB
/
Copy pathutil_test.go
File metadata and controls
49 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright © 2022-2023 Christian R. Vozar
// Licensed under the MIT License. All rights reserved.
package criprof
import (
"os"
"testing"
)
func TestEnvironMap(t *testing.T) {
// Set a test environment variable
testKey := "CRIPROF_TEST_VAR"
testValue := "test_value"
os.Setenv(testKey, testValue)
defer os.Unsetenv(testKey)
// Call environMap
result := environMap()
// Verify it returns a map
if result == nil {
t.Fatal("environMap() returned nil")
}
// Verify our test variable is in the map
if val, exists := result[testKey]; !exists {
t.Errorf("environMap() missing key %s", testKey)
} else if val != testValue {
t.Errorf("environMap()[%s] = %v, expected %v", testKey, val, testValue)
}
// Verify PATH exists (should be in any environment)
if _, exists := result["PATH"]; !exists {
t.Error("environMap() missing PATH variable")
}
}
func TestEnvironmentVariablesInitialization(t *testing.T) {
// EnvironmentVariables should be populated at init
if EnvironmentVariables == nil {
t.Fatal("EnvironmentVariables is nil after package initialization")
}
// Should contain common environment variables
if len(EnvironmentVariables) == 0 {
t.Error("EnvironmentVariables is empty")
}
}