Skip to content
Snippets Groups Projects
Commit b6c9e4aa authored by Dan Lorenc's avatar Dan Lorenc
Browse files

Fix string formatting for the IntegratedTime stamp.

Also check it in the test.
parent 6c2e068a
No related branches found
No related tags found
No related merge requests found
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"strconv" "strconv"
"time"
"github.com/projectrekor/rekor/cmd/cli/app/format" "github.com/projectrekor/rekor/cmd/cli/app/format"
"github.com/projectrekor/rekor/pkg/generated/client/entries" "github.com/projectrekor/rekor/pkg/generated/client/entries"
...@@ -38,7 +39,8 @@ type getCmdOutput struct { ...@@ -38,7 +39,8 @@ type getCmdOutput struct {
func (g *getCmdOutput) String() string { func (g *getCmdOutput) String() string {
s := fmt.Sprintf("Index: %d\n", g.LogIndex) 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) s += fmt.Sprintf("Body: %s\n", g.Body)
return s return s
} }
......
...@@ -99,12 +99,17 @@ func TestGet(t *testing.T) { ...@@ -99,12 +99,17 @@ func TestGet(t *testing.T) {
out = runCli(t, "get", "--format=json", "--uuid", uuid) out = runCli(t, "get", "--format=json", "--uuid", uuid)
// The output here should be in JSON with this structure: // The output here should be in JSON with this structure:
g := struct { g := struct {
Body string Body string
LogIndex int LogIndex int
IntegratedTime int64
}{} }{}
if err := json.Unmarshal([]byte(out), &g); err != nil { if err := json.Unmarshal([]byte(out), &g); err != nil {
t.Error(err) t.Error(err)
} }
if g.IntegratedTime == 0 {
t.Errorf("Expected IntegratedTime to be set. Got %s", out)
}
// Get it with the logindex as well // Get it with the logindex as well
runCli(t, "get", "--format=json", "--log-index", strconv.Itoa(g.LogIndex)) runCli(t, "get", "--format=json", "--log-index", strconv.Itoa(g.LogIndex))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment