diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-08-19 21:30:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 21:30:01 +0800 |
commit | c6143edb4425cb59266dea30bc85877a49355aa6 (patch) | |
tree | 6e500b7135115574e8b68422becba8eff531a51b /internal/osutil/osutil_test.go | |
parent | 252d0fd9775e40b641e5edc6facb147741c3b217 (diff) |
osutil: update docstring and tests (#6255)
Diffstat (limited to 'internal/osutil/osutil_test.go')
-rw-r--r-- | internal/osutil/osutil_test.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/internal/osutil/osutil_test.go b/internal/osutil/osutil_test.go index 73a45836..65ead618 100644 --- a/internal/osutil/osutil_test.go +++ b/internal/osutil/osutil_test.go @@ -81,16 +81,10 @@ func TestIsExist(t *testing.T) { } func TestCurrentUsername(t *testing.T) { - // Make sure it does not blow up - CurrentUsername() -} - -func TestCurrentUsernamePrefersEnvironmentVariable(t *testing.T) { - // Some users/scripts expect that they can change the current username via environment variables - if userBak, ok := os.LookupEnv("USER"); ok { - defer os.Setenv("USER", userBak) + if oldUser, ok := os.LookupEnv("USER"); ok { + defer func() { _ = os.Setenv("USER", oldUser) }() } else { - defer os.Unsetenv("USER") + defer func() { _ = os.Unsetenv("USER") }() } if err := os.Setenv("USER", "__TESTING::USERNAME"); err != nil { |