Skip to content

Commit

Permalink
Revert "Merge pull request #3 from toolbox-labo/b/feature/getmsg-even…
Browse files Browse the repository at this point in the history
…ing"

This reverts commit 86906c1, reversing
changes made to 171ed44.
  • Loading branch information
ymtdzzz committed Jul 17, 2023
1 parent 86906c1 commit d8700ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ func main() {
func getMSG(d *time.Time) string {
if d.Hour() <= 12 {
return "Good morning"
} else if d.Hour() >= 18 {
return "Good evening"
}
return "Good afternoon"
}
Expand Down
13 changes: 4 additions & 9 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ func TestGetMSG(t *testing.T) {
time: time.Date(2023, time.July, 17, 13, 0, 0, 1, time.UTC),
want: "Good afternoon",
},
{
name: "evening",
time: time.Date(2023, time.July, 17, 18, 0, 0, 1, time.UTC),
want: "Good evening",
},
}

for _, tt := range tests {
Expand All @@ -41,19 +36,19 @@ func TestGetMSG(t *testing.T) {
}

func TestGreeting(t *testing.T) {
evening := time.Date(2023, time.July, 17, 18, 0, 0, 0, time.UTC)
afternoon := time.Date(2023, time.July, 17, 18, 0, 0, 0, time.UTC)

tests := []struct {
name string
want string
}{
{
name: "John",
want: "Good evening, John",
want: "Good afternoon, John",
},
{
name: "Tarou",
want: "Good evening, Tarou",
want: "Good afternoon, Tarou",
},
{
name: "TooLongName!", // over 11 chars => Longname
Expand All @@ -63,7 +58,7 @@ func TestGreeting(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := greeting(tt.name, &evening)
got := greeting(tt.name, &afternoon)
if tt.want != got {
t.Errorf("Unexpected result. want: %s, got: %s", tt.want, got)
}
Expand Down

0 comments on commit d8700ce

Please sign in to comment.