From 2feb8d103c1acc3c3302ee0be08e62a8e610f3ee Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 8 Jun 2022 03:49:13 +0800 Subject: [PATCH] more tests Signed-off-by: Kevin Su --- .../ioutils/remote_file_output_writer_test.go | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go diff --git a/go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go b/go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go new file mode 100644 index 000000000..03b48e80c --- /dev/null +++ b/go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go @@ -0,0 +1,49 @@ +package ioutils + +import ( + "context" + "testing" + + "github.com/flyteorg/flytestdlib/promutils" + "github.com/flyteorg/flytestdlib/storage" + "github.com/stretchr/testify/assert" +) + +func TestRemoteFileOutputWriter(t *testing.T) { + ctx := context.TODO() + memStore, err := storage.NewDataStore(&storage.Config{ + Type: storage.TypeMemory, + }, promutils.NewTestScope()) + assert.Nil(t, err) + + outputPrefix := storage.DataReference("output") + rawOutputPrefix := storage.DataReference("sandbox") + previousCheckpointPath := storage.DataReference("checkpoint") + + checkpointPath := NewCheckpointRemoteFilePaths( + ctx, + memStore, + outputPrefix, + NewRawOutputPaths(ctx, rawOutputPrefix), + previousCheckpointPath) + + t.Run("Test NewCheckpointRemoteFilePaths", func(t *testing.T) { + assert.Equal(t, previousCheckpointPath, checkpointPath.GetPreviousCheckpointsPrefix()) + assert.Equal(t, outputPrefix, checkpointPath.GetOutputPrefixPath()) + + assert.Equal(t, constructPath(memStore, rawOutputPrefix, CheckpointPrefix), checkpointPath.GetCheckpointPrefix()) + assert.Equal(t, constructPath(memStore, outputPrefix, OutputsSuffix), checkpointPath.GetOutputPath()) + assert.Equal(t, constructPath(memStore, outputPrefix, deckSuffix), checkpointPath.GetDeckPath()) + assert.Equal(t, constructPath(memStore, outputPrefix, ErrorsSuffix), checkpointPath.GetErrorPath()) + assert.Equal(t, constructPath(memStore, outputPrefix, FuturesSuffix), checkpointPath.GetFuturesPath()) + }) + + t.Run("Test NewRemoteFileOutputWriter", func(t *testing.T) { + p := NewRemoteFileOutputWriter(ctx, memStore, checkpointPath) + + assert.Equal(t, constructPath(memStore, rawOutputPrefix, CheckpointPrefix), p.GetCheckpointPrefix()) + assert.Equal(t, constructPath(memStore, outputPrefix, OutputsSuffix), p.GetOutputPath()) + assert.Equal(t, constructPath(memStore, outputPrefix, deckSuffix), p.GetDeckPath()) + assert.Equal(t, constructPath(memStore, outputPrefix, ErrorsSuffix), p.GetErrorPath()) + }) +}