mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
24 lines
410 B
Go
24 lines
410 B
Go
package fsutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestUmask(t *testing.T) {
|
|
for _, vn := range []string{"GOPASS_UMASK", "PASSWORD_STORE_UMASK"} {
|
|
for in, out := range map[string]int{
|
|
"002": 0o2,
|
|
"0777": 0o777,
|
|
"000": 0,
|
|
"07557575": 0o77,
|
|
} {
|
|
t.Run(vn, func(t *testing.T) {
|
|
t.Setenv(vn, in)
|
|
assert.Equal(t, out, Umask())
|
|
})
|
|
}
|
|
}
|
|
}
|