-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the fetcher interface to exclude cmdCtx (#61)
* Refactored the fetcher interface to exclude cmdCtx and added builder Signed-off-by: Prafulla Mahindrakar <[email protected]> * Further refactoring and fixed tests Signed-off-by: Prafulla Mahindrakar <[email protected]> * Added more coverage and fixed linter issues Signed-off-by: Prafulla Mahindrakar <[email protected]> * Still more coverage Signed-off-by: Prafulla Mahindrakar <[email protected]> * Still more coverage Signed-off-by: Prafulla Mahindrakar <[email protected]> * lint issue Signed-off-by: Prafulla Mahindrakar <[email protected]> * lint issue Signed-off-by: Prafulla Mahindrakar <[email protected]> * morelint issue Signed-off-by: Prafulla Mahindrakar <[email protected]> * Renamed Fetcher to be AdminFetcherExt and initialized it cmdCtx Signed-off-by: Prafulla Mahindrakar <[email protected]>
- Loading branch information
1 parent
f103e41
commit a0632f0
Showing
27 changed files
with
1,218 additions
and
428 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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,90 @@ | ||
package get | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"google.golang.org/protobuf/types/known/timestamppb" | ||
) | ||
|
||
func TestTaskInputs(t *testing.T) { | ||
taskInputs := map[string]*core.Variable{} | ||
t.Run("nil task", func(t *testing.T) { | ||
retValue := TaskInputs(nil) | ||
assert.Equal(t, taskInputs, retValue) | ||
}) | ||
t.Run("valid inputs", func(t *testing.T) { | ||
task := createTask() | ||
retValue := TaskInputs(task) | ||
assert.Equal(t, task.Closure.CompiledTask.Template.Interface.Inputs.Variables, retValue) | ||
}) | ||
t.Run("closure compiled task nil", func(t *testing.T) { | ||
task := createTask() | ||
task.Closure.CompiledTask = nil | ||
retValue := TaskInputs(task) | ||
assert.Equal(t, taskInputs, retValue) | ||
}) | ||
t.Run("closure compiled task template nil", func(t *testing.T) { | ||
task := createTask() | ||
task.Closure.CompiledTask.Template = nil | ||
retValue := TaskInputs(task) | ||
assert.Equal(t, taskInputs, retValue) | ||
}) | ||
t.Run("closure compiled task template interface nil", func(t *testing.T) { | ||
task := createTask() | ||
task.Closure.CompiledTask.Template.Interface = nil | ||
retValue := TaskInputs(task) | ||
assert.Equal(t, taskInputs, retValue) | ||
}) | ||
t.Run("closure compiled task template interface input nil", func(t *testing.T) { | ||
task := createTask() | ||
task.Closure.CompiledTask.Template.Interface.Inputs = nil | ||
retValue := TaskInputs(task) | ||
assert.Equal(t, taskInputs, retValue) | ||
}) | ||
} | ||
|
||
func createTask() *admin.Task { | ||
sortedListLiteralType := core.Variable{ | ||
Type: &core.LiteralType{ | ||
Type: &core.LiteralType_CollectionType{ | ||
CollectionType: &core.LiteralType{ | ||
Type: &core.LiteralType_Simple{ | ||
Simple: core.SimpleType_INTEGER, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
variableMap := map[string]*core.Variable{ | ||
"sorted_list1": &sortedListLiteralType, | ||
"sorted_list2": &sortedListLiteralType, | ||
} | ||
|
||
inputs := &core.VariableMap{ | ||
Variables: variableMap, | ||
} | ||
typedInterface := &core.TypedInterface{ | ||
Inputs: inputs, | ||
} | ||
taskTemplate := &core.TaskTemplate{ | ||
Interface: typedInterface, | ||
} | ||
compiledTask := &core.CompiledTask{ | ||
Template: taskTemplate, | ||
} | ||
return &admin.Task{ | ||
Id: &core.Identifier{ | ||
Name: "task1", | ||
Version: "v2", | ||
}, | ||
Closure: &admin.TaskClosure{ | ||
CreatedAt: ×tamppb.Timestamp{Seconds: 1, Nanos: 0}, | ||
CompiledTask: compiledTask, | ||
}, | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.