Skip to content

Commit

Permalink
Adjust release command tests for different timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Dec 31, 2019
1 parent 05669a0 commit 71fbe4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 6 additions & 8 deletions newreleases/cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,12 @@ func printReleasesTable(cmd *cobra.Command, releases []newreleases.Release) {
}

func printReleaseTable(cmd *cobra.Command, r *newreleases.Release) {
table := newTable(cmd.OutOrStdout())
table.Append([]string{"Version:", r.Version})
table.Append([]string{"Date:", r.Date.Local().String()})
table.Append([]string{"Pre-Release:", yesNo(r.IsPrerelease)})
table.Append([]string{"Has Note:", yesNo(r.HasNote)})
table.Append([]string{"Updated:", yesNo(r.IsUpdated)})
table.Append([]string{"Excluded:", yesNo(r.IsExcluded)})
table.Render()
cmd.Println("Version: ", r.Version)
cmd.Println("Date: ", r.Date.Local().String())
cmd.Println("Pre-Release: ", yesNo(r.IsPrerelease))
cmd.Println("Has Note: ", yesNo(r.HasNote))
cmd.Println("Updated: ", yesNo(r.IsUpdated))
cmd.Println("Excluded: ", yesNo(r.IsExcluded))
}

func printReleaseNote(cmd *cobra.Command, n *newreleases.ReleaseNote) {
Expand Down
7 changes: 5 additions & 2 deletions newreleases/cmd/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bytes"
"context"
"fmt"
"strings"
"testing"

"newreleases.io/cmd/newreleases/cmd"
Expand Down Expand Up @@ -52,7 +53,9 @@ func TestReleaseCmd_List(t *testing.T) {
{Version: "v1.18.88", Date: newTime(t, "2019-08-11T19:57:01Z"), IsExcluded: true},
}, nil, 1, nil),
wantOutputFunc: func() string {
return fmt.Sprintf("VERSION DATE PRE-RELEASE HAS NOTE UPDATED EXCLUDED \nv1.25.0 %s no no no no \nv1.21.6 %s yes no no no \nv1.21.5 %s no yes no no \nv1.20.0 %s no no yes no \nv1.18.88 %s no no no yes \n",
dateHeaderSep := strings.Repeat(" ", len(newTime(t, "2019-10-22T01:45:55Z").Local().String())-1)
return fmt.Sprintf("VERSION DATE%sPRE-RELEASE HAS NOTE UPDATED EXCLUDED \nv1.25.0 %s no no no no \nv1.21.6 %s yes no no no \nv1.21.5 %s no yes no no \nv1.20.0 %s no no yes no \nv1.18.88 %s no no no yes \n",
dateHeaderSep,
newTime(t, "2019-10-22T01:45:55Z").Local(),
newTime(t, "2019-09-21T11:25:00Z").Local(),
newTime(t, "2019-09-20T01:03:00Z").Local(),
Expand Down Expand Up @@ -108,7 +111,7 @@ func TestReleaseCmd_Get(t *testing.T) {
{Version: "v0.1.0", Date: newTime(t, "2019-10-22T01:45:55Z")},
}, nil, 1, nil),
wantOutputFunc: func() string {
return fmt.Sprintf("Version: v0.1.0 \nDate: %s \nPre-Release: no \nHas Note: no \nUpdated: no \nExcluded: no \n",
return fmt.Sprintf("Version: v0.1.0\nDate: %s\nPre-Release: no\nHas Note: no\nUpdated: no\nExcluded: no\n",
newTime(t, "2019-10-22T01:45:55Z").Local(),
)
},
Expand Down

0 comments on commit 71fbe4e

Please sign in to comment.