-
Notifications
You must be signed in to change notification settings - Fork 272
Expand file tree
/
Copy pathenv_test.go
More file actions
66 lines (50 loc) · 1.25 KB
/
env_test.go
File metadata and controls
66 lines (50 loc) · 1.25 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package utils
import (
"runtime"
"testing"
"github.com/stretchr/testify/assert"
)
func TestTargetArch_DefaultsToHostArch(t *testing.T) {
t.Setenv("TARGET_ARCH", "")
result := TargetArch()
assert.Equal(t, runtime.GOARCH, result)
}
func TestTargetArch_RespectsValidOverride(t *testing.T) {
tests := []struct {
name string
arch string
expected string
}{
{name: "amd64", arch: "amd64", expected: "amd64"},
{name: "arm64", arch: "arm64", expected: "arm64"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv("TARGET_ARCH", tt.arch)
result := TargetArch()
assert.Equal(t, tt.expected, result)
})
}
}
func TestTargetArch_NormalizesAliases(t *testing.T) {
tests := []struct {
name string
arch string
expected string
}{
{name: "x86_64 → amd64", arch: "x86_64", expected: "amd64"},
{name: "aarch64 → arm64", arch: "aarch64", expected: "arm64"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv("TARGET_ARCH", tt.arch)
result := TargetArch()
assert.Equal(t, tt.expected, result)
})
}
}
func TestTargetArch_FallsBackOnUnknown(t *testing.T) {
t.Setenv("TARGET_ARCH", "mips")
result := TargetArch()
assert.Equal(t, runtime.GOARCH, result)
}