You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
381 B

  1. package user
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. func TestCurrentUsername(t *testing.T) {
  7. os.Setenv("USER", "")
  8. os.Setenv("USERNAME", "foobar")
  9. user := CurrentUsername()
  10. if user != "foobar" {
  11. t.Errorf("expected foobar as user, got: %s", user)
  12. }
  13. os.Setenv("USER", "gitea")
  14. user = CurrentUsername()
  15. if user != "gitea" {
  16. t.Errorf("expected gitea as user, got: %s", user)
  17. }
  18. }