From b6c9e4aac80958a2e94ec68e10a2b7a699ca04a6 Mon Sep 17 00:00:00 2001
From: Dan Lorenc <dlorenc@google.com>
Date: Thu, 21 Jan 2021 06:39:07 -0600
Subject: [PATCH] Fix string formatting for the IntegratedTime stamp.

Also check it in the test.
---
 cmd/cli/app/get.go | 4 +++-
 tests/e2e_test.go  | 9 +++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/cmd/cli/app/get.go b/cmd/cli/app/get.go
index c46610d..ff5c885 100644
--- a/cmd/cli/app/get.go
+++ b/cmd/cli/app/get.go
@@ -20,6 +20,7 @@ import (
 	"errors"
 	"fmt"
 	"strconv"
+	"time"
 
 	"github.com/projectrekor/rekor/cmd/cli/app/format"
 	"github.com/projectrekor/rekor/pkg/generated/client/entries"
@@ -38,7 +39,8 @@ type getCmdOutput struct {
 
 func (g *getCmdOutput) String() string {
 	s := fmt.Sprintf("Index: %d\n", g.LogIndex)
-	s += fmt.Sprintf("IntegratedTime: %d\n", g.IntegratedTime)
+	dt := time.Unix(g.IntegratedTime, 0).UTC().Format(time.RFC3339)
+	s += fmt.Sprintf("IntegratedTime: %s\n", dt)
 	s += fmt.Sprintf("Body: %s\n", g.Body)
 	return s
 }
diff --git a/tests/e2e_test.go b/tests/e2e_test.go
index 6f33cfc..192d4b5 100644
--- a/tests/e2e_test.go
+++ b/tests/e2e_test.go
@@ -99,12 +99,17 @@ func TestGet(t *testing.T) {
 	out = runCli(t, "get", "--format=json", "--uuid", uuid)
 	// The output here should be in JSON with this structure:
 	g := struct {
-		Body     string
-		LogIndex int
+		Body           string
+		LogIndex       int
+		IntegratedTime int64
 	}{}
 	if err := json.Unmarshal([]byte(out), &g); err != nil {
 		t.Error(err)
 	}
+
+	if g.IntegratedTime == 0 {
+		t.Errorf("Expected IntegratedTime to be set. Got %s", out)
+	}
 	// Get it with the logindex as well
 	runCli(t, "get", "--format=json", "--log-index", strconv.Itoa(g.LogIndex))
 
-- 
GitLab