Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw committed Oct 12, 2022
1 parent 4654389 commit 4fa6067
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/tasks/pluginmachinery/io/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type OutputReader interface {
Read(ctx context.Context) (*core.LiteralMap, *ExecutionError, error)
// DeckExists checks if the deck file has been generated.
DeckExists(ctx context.Context) (bool, error)
// GetOutputMetadata get the metadata from task's output, like deck uri
// GetOutputMetadata get the metadata from the output of tasks, such as deck URI.
GetOutputMetadata(ctx context.Context) map[string]string
}

Expand Down
3 changes: 3 additions & 0 deletions go/tasks/pluginmachinery/ioutils/in_memory_output_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (r InMemoryOutputReader) DeckExists(_ context.Context) (bool, error) {
}

func (r InMemoryOutputReader) GetOutputMetadata(_ context.Context) map[string]string {
if r.DeckPath == nil {
return map[string]string{}
}
return map[string]string{deckURIKey: r.DeckPath.String()}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func TestInMemoryOutputReader(t *testing.T) {
or := NewInMemoryOutputReader(&flyteIdlCore.LiteralMap{Literals: lt}, &deckPath, nil)

assert.Equal(t, &deckPath, or.DeckPath)
assert.Equal(t, deckPath.String(), or.GetOutputMetadata(context.Background())[deckURIKey])
ctx := context.TODO()

ok, err := or.IsError(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func TestReadOrigin(t *testing.T) {
exists, err := r.DeckExists(ctx)
assert.NoError(t, err)
assert.True(t, exists)
assert.Equal(t, "deck.html", r.GetOutputMetadata(ctx)[deckURIKey])
})

t.Run("system", func(t *testing.T) {
Expand Down

0 comments on commit 4fa6067

Please sign in to comment.