From a2a3f36bf00e7a5eff963828ad24946c4b334a35 Mon Sep 17 00:00:00 2001 From: Yuxiang Cao Date: Thu, 16 May 2024 12:56:27 -0700 Subject: [PATCH] use timestamp string for TestTime --- cmd/loadTest.go | 2 +- cmd/load_test_types.go | 4 ++-- cmd/load_test_types_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/loadTest.go b/cmd/loadTest.go index fa09b34..adc6680 100644 --- a/cmd/loadTest.go +++ b/cmd/loadTest.go @@ -216,7 +216,7 @@ func loadTest(name string, setup setupFunc, test testFunc, cleanup cleanupFunc) } testSummary := &TestSummary{ - TestTime: testTime, + TestTime: testTime.Format(time.RFC3339), Config: &testConfig, Result: &testResult, } diff --git a/cmd/load_test_types.go b/cmd/load_test_types.go index 411160c..8ba1400 100644 --- a/cmd/load_test_types.go +++ b/cmd/load_test_types.go @@ -19,7 +19,7 @@ import ( ) type TestSummary struct { - TestTime time.Time `json:"test_time" yaml:"test_time"` + TestTime string `json:"test_time" yaml:"test_time"` // ISO 8601 timestamp string Config *TestConfig `json:"config" yaml:"config"` Result *TestResult `json:"result" yaml:"result"` } @@ -170,7 +170,7 @@ type TestSummaryPlainWriter interface { func (ts *TestSummary) WritePlain(w io.Writer) error { fmt.Fprintf(w, "-----BEGIN TEST SUMMARY-----\n") - fmt.Fprintf(w, "TestTime: %v\n", ts.TestTime.Format(time.RFC3339)) + fmt.Fprintf(w, "TestTime: %v\n", ts.TestTime) ts.Config.Print(w) fmt.Fprintf(w, "\n") ts.Result.Print(w) diff --git a/cmd/load_test_types_test.go b/cmd/load_test_types_test.go index 5fe8adc..62cf0f8 100644 --- a/cmd/load_test_types_test.go +++ b/cmd/load_test_types_test.go @@ -58,7 +58,7 @@ func TestWriteTestSummaryToJson(t *testing.T) { func newTestSummary() *TestSummary { loadTest := &TestSummary{ - TestTime: time.Unix(1715032508, 0), + TestTime: time.Now().Format(time.RFC3339), Config: &TestConfig{ TestName: "Test1", ServerName: "localhost",