summaryrefslogtreecommitdiffstats
path: root/modules/user/user_test.go
blob: d7df15153166ae2416899aaddb5cccd0d3049697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package user

import (
	"os"
	"testing"
)

func TestCurrentUsername(t *testing.T) {
	os.Setenv("USER", "")
	os.Setenv("USERNAME", "foobar")

	user := CurrentUsername()
	if user != "foobar" {
		t.Errorf("expected foobar as user, got: %s", user)
	}

	os.Setenv("USER", "gitea")
	user = CurrentUsername()
	if user != "gitea" {
		t.Errorf("expected gitea as user, got: %s", user)
	}
}