Skip to content

Commit

Permalink
Merge pull request #3 from MeztliRA/add-short-message
Browse files Browse the repository at this point in the history
Add short message
  • Loading branch information
MeztliRA authored Mar 26, 2021
2 parents 8c4c9a4 + 5715ce7 commit af992fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
15 changes: 13 additions & 2 deletions weekdays.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
)

const (
messageWeekday = "Its the weekday!"
messageWeekend = "Its the weekend!"
messageWeekday = "Its the weekday!"
messageWeekend = "Its the weekend!"
messageWeekdayShort = "weekday!"
messageWeekendShort = "weekend!"
)

func IsWeekday() bool {
Expand Down Expand Up @@ -35,3 +37,12 @@ func Message() string {
return messageWeekday
}
}

func MessageShort() string {
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
return messageWeekendShort
default:
return messageWeekdayShort
}
}
20 changes: 18 additions & 2 deletions weekdays_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import (
)

const (
messageWeekday = "Its the weekday!"
messageWeekend = "Its the weekend!"
messageWeekday = "Its the weekday!"
messageWeekend = "Its the weekend!"
messageWeekdayShort = "weekday!"
messageWeekendShort = "weekend!"
)

func TestMessage(t *testing.T) {
Expand All @@ -25,3 +27,17 @@ func TestMessage(t *testing.T) {
}
}
}

func TestMessageShort(t *testing.T) {
got := weekdays.MessageShort()
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
if got != messageWeekendShort {
t.Errorf("Message is not the same")
}
default:
if got != messageWeekdayShort {
t.Errorf("Message is not the same")
}
}
}

0 comments on commit af992fd

Please sign in to comment.