forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GeneratedNameMaxLength property (flyteorg#167)
- Loading branch information
Showing
16 changed files
with
223 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package core_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/core" | ||
"github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/core/mocks" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func TestLoadPlugin(t *testing.T) { | ||
corePluginType := "core" | ||
|
||
t.Run("valid", func(t *testing.T) { | ||
corePlugin := &mocks.Plugin{} | ||
corePlugin.On("GetID").Return(corePluginType) | ||
corePlugin.OnGetProperties().Return(core.PluginProperties{}) | ||
|
||
corePluginEntry := core.PluginEntry{ | ||
ID: corePluginType, | ||
RegisteredTaskTypes: []core.TaskType{corePluginType}, | ||
LoadPlugin: func(ctx context.Context, iCtx core.SetupContext) (core.Plugin, error) { | ||
return corePlugin, nil | ||
}, | ||
} | ||
setupCtx := mocks.SetupContext{} | ||
p, err := core.LoadPlugin(context.TODO(), &setupCtx, corePluginEntry) | ||
assert.NilError(t, err) | ||
assert.Equal(t, corePluginType, p.GetID()) | ||
}) | ||
|
||
t.Run("valid GeneratedNameMaxLength", func(t *testing.T) { | ||
corePlugin := &mocks.Plugin{} | ||
corePlugin.On("GetID").Return(corePluginType) | ||
length := 10 | ||
corePlugin.OnGetProperties().Return(core.PluginProperties{ | ||
GeneratedNameMaxLength: &length, | ||
}) | ||
|
||
corePluginEntry := core.PluginEntry{ | ||
ID: corePluginType, | ||
RegisteredTaskTypes: []core.TaskType{corePluginType}, | ||
LoadPlugin: func(ctx context.Context, iCtx core.SetupContext) (core.Plugin, error) { | ||
return corePlugin, nil | ||
}, | ||
} | ||
setupCtx := mocks.SetupContext{} | ||
p, err := core.LoadPlugin(context.TODO(), &setupCtx, corePluginEntry) | ||
assert.NilError(t, err) | ||
assert.Equal(t, corePluginType, p.GetID()) | ||
}) | ||
|
||
t.Run("valid GeneratedNameMaxLength", func(t *testing.T) { | ||
corePlugin := &mocks.Plugin{} | ||
corePlugin.On("GetID").Return(corePluginType) | ||
length := 10 | ||
corePlugin.OnGetProperties().Return(core.PluginProperties{ | ||
GeneratedNameMaxLength: &length, | ||
}) | ||
|
||
corePluginEntry := core.PluginEntry{ | ||
ID: corePluginType, | ||
RegisteredTaskTypes: []core.TaskType{corePluginType}, | ||
LoadPlugin: func(ctx context.Context, iCtx core.SetupContext) (core.Plugin, error) { | ||
return corePlugin, nil | ||
}, | ||
} | ||
setupCtx := mocks.SetupContext{} | ||
_, err := core.LoadPlugin(context.TODO(), &setupCtx, corePluginEntry) | ||
assert.NilError(t, err) | ||
}) | ||
|
||
t.Run("invalid GeneratedNameMaxLength", func(t *testing.T) { | ||
corePlugin := &mocks.Plugin{} | ||
corePlugin.On("GetID").Return(corePluginType) | ||
length := 5 | ||
corePlugin.OnGetProperties().Return(core.PluginProperties{ | ||
GeneratedNameMaxLength: &length, | ||
}) | ||
|
||
corePluginEntry := core.PluginEntry{ | ||
ID: corePluginType, | ||
RegisteredTaskTypes: []core.TaskType{corePluginType}, | ||
LoadPlugin: func(ctx context.Context, iCtx core.SetupContext) (core.Plugin, error) { | ||
return corePlugin, nil | ||
}, | ||
} | ||
setupCtx := mocks.SetupContext{} | ||
_, err := core.LoadPlugin(context.TODO(), &setupCtx, corePluginEntry) | ||
assert.Error(t, err, "GeneratedNameMaxLength needs to be greater then 8") | ||
}) | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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