This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kevin Su <pingsutw@apache.org>
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
go/tasks/pluginmachinery/ioutils/remote_file_output_writer_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
}) | ||
} |