From db30f6f417129ec8e45cc40cb7736bc6e2975d39 Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Thu, 13 Jul 2023 23:05:21 +0200 Subject: [PATCH] Create a mocked clock with time.Local timezone --- internal/manager/job_compilers/job_compilers_test.go | 11 ++++++----- .../manager/sleep_scheduler/sleep_scheduler_test.go | 2 +- internal/worker/common_test.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/manager/job_compilers/job_compilers_test.go b/internal/manager/job_compilers/job_compilers_test.go index 3fcccfaa..f6a179b4 100644 --- a/internal/manager/job_compilers/job_compilers_test.go +++ b/internal/manager/job_compilers/job_compilers_test.go @@ -57,7 +57,8 @@ func exampleSubmittedJob() api.SubmittedJob { func mockedClock(t *testing.T) clock.Clock { c := clock.NewMock() - now, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00") + //current_location, err := time.LoadLocation("Local") + now, err := time.ParseInLocation("2006-01-02T15:04:05", "2006-01-02T15:04:05", time.Local) assert.NoError(t, err) c.Set(now) return c @@ -250,13 +251,13 @@ func TestSimpleBlenderRenderOutputPathFieldReplacement(t *testing.T) { require.NotNil(t, aj) // The job compiler should have replaced the {timestamp} and {ext} fields. - assert.Equal(t, "/root/2006-01-02_090405/jobname/######", aj.Settings["render_output_path"]) + assert.Equal(t, "/root/2006-01-02_150405/jobname/######", aj.Settings["render_output_path"]) // Tasks should have been created to render the frames: 1-3, 4-6, 7-9, 10, and video-encoding require.Len(t, aj.Tasks, 5) t0 := aj.Tasks[0] expectCliArgs := []interface{}{ // They are strings, but Goja doesn't know that and will produce an []interface{}. - "--render-output", "/root/2006-01-02_090405/jobname/######", + "--render-output", "/root/2006-01-02_150405/jobname/######", "--render-format", sj.Settings.AdditionalProperties["format"].(string), "--render-frame", "1..3", } @@ -271,8 +272,8 @@ func TestSimpleBlenderRenderOutputPathFieldReplacement(t *testing.T) { tVideo := aj.Tasks[4] // This should be a video encoding task assert.EqualValues(t, AuthoredCommandParameters{ "exe": "ffmpeg", - "inputGlob": "/root/2006-01-02_090405/jobname/*.png", - "outputFile": "/root/2006-01-02_090405/jobname/scene123-1-10.mp4", + "inputGlob": "/root/2006-01-02_150405/jobname/*.png", + "outputFile": "/root/2006-01-02_150405/jobname/scene123-1-10.mp4", "fps": int64(24), "args": expectedFramesToVideoArgs, }, tVideo.Commands[0].Parameters) diff --git a/internal/manager/sleep_scheduler/sleep_scheduler_test.go b/internal/manager/sleep_scheduler/sleep_scheduler_test.go index 65dfe3d8..9b8358bc 100644 --- a/internal/manager/sleep_scheduler/sleep_scheduler_test.go +++ b/internal/manager/sleep_scheduler/sleep_scheduler_test.go @@ -269,7 +269,7 @@ func testFixtures(t *testing.T) (*SleepScheduler, TestMocks, context.Context) { ctx := context.Background() mockedClock := clock.NewMock() - mockedNow, err := time.Parse(time.RFC3339, "2022-06-07T11:14:47+02:00") + mockedNow, err := time.ParseInLocation("2006-01-02T15:04:05", "2022-06-07T11:14:47", time.Local) if err != nil { panic(err) } diff --git a/internal/worker/common_test.go b/internal/worker/common_test.go index 05894bf5..ec5be2df 100644 --- a/internal/worker/common_test.go +++ b/internal/worker/common_test.go @@ -12,7 +12,7 @@ import ( func mockedClock(t *testing.T) *clock.Mock { c := clock.NewMock() - now, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05+07:00") + now, err := time.ParseInLocation("2006-01-02T15:04:05", "2006-01-02T15:04:05", time.Local) assert.NoError(t, err) c.Set(now) return c -- 2.30.2