Example #1
0
func Test_User(t *testing.T) {
	user := database.NewUser("testuser", "", false)

	if user.IsOnline() {
		t.Errorf("Newly created user shouldn't be online")
	}

	user.SetOnline(true)

	testutils.Assert(user.IsOnline(), t, "Call to SetOnline(true) failed")
	testutils.Assert(user.GetColorMode() == types.ColorModeNone, t, "Newly created user should have a color mode of None")

	user.SetColorMode(types.ColorModeLight)

	testutils.Assert(user.GetColorMode() == types.ColorModeLight, t, "Call to SetColorMode(types.ColorModeLight) failed")

	user.SetColorMode(types.ColorModeDark)

	testutils.Assert(user.GetColorMode() == types.ColorModeDark, t, "Call to SetColorMode(types.ColorModeDark) failed")

	pw := "password"
	user.SetPassword(pw)

	testutils.Assert(user.VerifyPassword(pw), t, "User password verification failed")

	width := 11
	height := 12
	user.SetWindowSize(width, height)

	testWidth, testHeight := user.GetWindowSize()

	testutils.Assert(testWidth == width && testHeight == height, t, "Call to SetWindowSize() failed")

	terminalType := "fake terminal type"
	user.SetTerminalType(terminalType)

	testutils.Assert(terminalType == user.GetTerminalType(), t, "Call to SetTerminalType() failed")
}
Example #2
0
func CreateUser(name string, password string, admin bool) types.User {
	return db.NewUser(name, password, admin)
}