mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Remove unnecessary parameter passing in WtfApp
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
63aa353db3
commit
a746ab6975
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
"github.com/wtfutil/wtf/support"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const exitMessageHeader = `
|
const exitMessageHeader = `
|
||||||
@ -25,14 +24,14 @@ const exitMessageHeader = `
|
|||||||
func (wtfApp *WtfApp) DisplayExitMessage() {
|
func (wtfApp *WtfApp) DisplayExitMessage() {
|
||||||
exitMessageIsDisplayable := readDisplayableConfig(wtfApp.config)
|
exitMessageIsDisplayable := readDisplayableConfig(wtfApp.config)
|
||||||
|
|
||||||
wtfApp.displayExitMsg(wtfApp.ghUser, exitMessageIsDisplayable)
|
wtfApp.displayExitMsg(exitMessageIsDisplayable)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
func (wtfApp *WtfApp) displayExitMsg(ghUser *support.GitHubUser, exitMessageIsDisplayable bool) string {
|
func (wtfApp *WtfApp) displayExitMsg(exitMessageIsDisplayable bool) string {
|
||||||
// If a sponsor or contributor and opt out of seeing the exit message, do not display it
|
// If a sponsor or contributor and opt out of seeing the exit message, do not display it
|
||||||
if (ghUser.IsContributor || ghUser.IsSponsor) && !exitMessageIsDisplayable {
|
if (wtfApp.ghUser.IsContributor || wtfApp.ghUser.IsSponsor) && !exitMessageIsDisplayable {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +39,15 @@ func (wtfApp *WtfApp) displayExitMsg(ghUser *support.GitHubUser, exitMessageIsDi
|
|||||||
|
|
||||||
msgs = append(msgs, aurora.Magenta(exitMessageHeader).String())
|
msgs = append(msgs, aurora.Magenta(exitMessageHeader).String())
|
||||||
|
|
||||||
if ghUser.IsContributor {
|
if wtfApp.ghUser.IsContributor {
|
||||||
msgs = append(msgs, wtfApp.contributorThankYouMessage())
|
msgs = append(msgs, wtfApp.contributorThankYouMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
if ghUser.IsSponsor {
|
if wtfApp.ghUser.IsSponsor {
|
||||||
msgs = append(msgs, wtfApp.sponsorThankYouMessage())
|
msgs = append(msgs, wtfApp.sponsorThankYouMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ghUser.IsContributor && !ghUser.IsSponsor {
|
if !wtfApp.ghUser.IsContributor && !wtfApp.ghUser.IsSponsor {
|
||||||
msgs = append(msgs, wtfApp.supportRequestMessage())
|
msgs = append(msgs, wtfApp.supportRequestMessage())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,12 +52,12 @@ func Test_displayExitMessage(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
wtfApp := WtfApp{}
|
wtfApp := WtfApp{}
|
||||||
ghUser := &support.GitHubUser{
|
wtfApp.ghUser = &support.GitHubUser{
|
||||||
IsContributor: tt.isContributor,
|
IsContributor: tt.isContributor,
|
||||||
IsSponsor: tt.isSponsor,
|
IsSponsor: tt.isSponsor,
|
||||||
}
|
}
|
||||||
|
|
||||||
actual := wtfApp.displayExitMsg(ghUser, tt.isDisplayable)
|
actual := wtfApp.displayExitMsg(tt.isDisplayable)
|
||||||
|
|
||||||
if tt.compareWith == "equals" {
|
if tt.compareWith == "equals" {
|
||||||
assert.Equal(t, actual, tt.expected)
|
assert.Equal(t, actual, tt.expected)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user