From 71fbe4ecaa7847ec86b8b6ba0fd72d971e33d16f Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Tue, 31 Dec 2019 10:50:53 +0100 Subject: [PATCH] Adjust release command tests for different timezones --- newreleases/cmd/release.go | 14 ++++++-------- newreleases/cmd/release_test.go | 7 +++++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/newreleases/cmd/release.go b/newreleases/cmd/release.go index a5243bb..548875d 100644 --- a/newreleases/cmd/release.go +++ b/newreleases/cmd/release.go @@ -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) { diff --git a/newreleases/cmd/release_test.go b/newreleases/cmd/release_test.go index 92ecc61..1f7be6b 100644 --- a/newreleases/cmd/release_test.go +++ b/newreleases/cmd/release_test.go @@ -9,6 +9,7 @@ import ( "bytes" "context" "fmt" + "strings" "testing" "newreleases.io/cmd/newreleases/cmd" @@ -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(), @@ -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(), ) },