From 94f09bfb6e217aee5c6db5ddc17fc142a636e718 Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Wed, 22 Jul 2020 10:21:56 -0400 Subject: [PATCH] remove duplicate license info (#8496) --- command/license.go | 2 -- command/license_get_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/command/license.go b/command/license.go index 1bc4f9f7c..ddb58c47c 100644 --- a/command/license.go +++ b/command/license.go @@ -74,8 +74,6 @@ func outputLicenseInfo(ui cli.Ui, lic *api.License, expired bool, validity strin fmt.Sprintf("License ID|%s", lic.LicenseID), fmt.Sprintf("Customer ID|%s", lic.CustomerID), expStr, - fmt.Sprintf("License ID|%s", lic.LicenseID), - fmt.Sprintf("Customer ID|%s", lic.CustomerID), fmt.Sprintf("Terminates At|%s", lic.TerminationTime.String()), fmt.Sprintf("Datacenter|%s", lic.InstallationID), } diff --git a/command/license_get_test.go b/command/license_get_test.go index c35132594..855af0d6b 100644 --- a/command/license_get_test.go +++ b/command/license_get_test.go @@ -2,7 +2,9 @@ package command import ( "testing" + "time" + "github.com/hashicorp/nomad/api" "github.com/mitchellh/cli" "github.com/stretchr/testify/require" ) @@ -26,3 +28,30 @@ func TestCommand_LicenseGet_OSSErr(t *testing.T) { require.Contains(t, ui.ErrorWriter.String(), "Nomad Enterprise only endpoint") } } + +func TestOutputLicenseReply(t *testing.T) { + now := time.Now() + lic := &api.LicenseReply{ + License: &api.License{ + LicenseID: "licenseID", + CustomerID: "customerID", + InstallationID: "*", + IssueTime: now, + StartTime: now, + ExpirationTime: now.Add(1 * time.Hour), + TerminationTime: now, + Product: "nomad", + Flags: map[string]interface{}{ + "": nil, + }, + }, + } + + ui := new(cli.MockUi) + + require.Equal(t, 0, OutputLicenseReply(ui, lic)) + + out := ui.OutputWriter.String() + require.Contains(t, out, "Customer ID") + require.Contains(t, out, "License ID") +}