refactor: User.SetColorIdx -> User.setColorIdx, preparing to abstract user

This commit is contained in:
Andrey Petrov committed 2016-08-29 09:58:17 -04:00
1 parent 33d7d26a17
commit 454777448f
3 files changed
+7 -8

No files matched your search

+4 -4
View File
@@ -44,7 +44,7 @@ func NewUser(identity Identifier) *User {
done: make(chan struct{}),
Ignored: set.New(),
}
u.SetColorIdx(rand.Int())
u.setColorIdx(rand.Int())
return &u
}
@@ -59,7 +59,7 @@ func NewUserScreen(identity Identifier, screen io.WriteCloser) *User {
// Rename the user with a new Identifier.
func (u *User) SetID(id string) {
u.Identifier.SetID(id)
u.SetColorIdx(rand.Int())
u.setColorIdx(rand.Int())
}
// ReplyTo returns the last user that messaged this user.
@@ -83,9 +83,9 @@ func (u *User) ToggleQuietMode() {
u.Config.Quiet = !u.Config.Quiet
}
// SetColorIdx will set the colorIdx to a specific value, primarily used for
// setColorIdx will set the colorIdx to a specific value, primarily used for
// testing.
func (u *User) SetColorIdx(idx int) {
func (u *User) setColorIdx(idx int) {
u.colorIdx = idx
}
+2 -2
View File
@@ -106,12 +106,12 @@ func (r *Room) HandleMsg(m message.Message) {
}
if skip && skipUser == user {
// Skip
// Skip self
return
}
if _, ok := m.(*message.AnnounceMsg); ok {
if user.Config.Quiet {
// Skip
// Skip announcements
return
}
}
+1 -2
View File
@@ -28,7 +28,6 @@ func TestHostGetPrompt(t *testing.T) {
var expected, actual string
u := message.NewUser(&Identity{id: "foo"})
u.SetColorIdx(2)
actual = GetPrompt(u)
expected = "[foo] "
@@ -38,7 +37,7 @@ func TestHostGetPrompt(t *testing.T) {
u.Config.Theme = &message.Themes[0]
actual = GetPrompt(u)
expected = "[\033[38;05;3mfoo\033[0m] "
expected = "[\033[38;05;88mfoo\033[0m] "
if actual != expected {
t.Errorf("Got: %q; Expected: %q", actual, expected)
}