Skip to content

Commit

Permalink
elaborate test
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Mar 27, 2024
1 parent bda92a9 commit 374f487
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,29 @@ def my_func(my_arg1, my_arg2, args):
require.Equal(suite.T(), expectedResult, result)
}

func (suite *StartosisInterpreterTestSuite) TestStartosisInterpreter_RandomMainFunctionAndParamsErrDueToDeprecatedArgsObject() {
func (suite *StartosisInterpreterTestSuite) TestStartosisInterpreter_MainFunctionAndParamsErrWhenOnlyDeprecatedArgsObjectProvided() {
script := `
def run(plan, args):
all_arg_values = args["arg1"] + ":" + args["arg2"]
return all_arg_values
`
mainFunctionName := "run"
// passing in only "args" dictionary is deprecated
inputArgs := `{"args": {"arg1": "arg1-value", "arg2": "arg2-value"}}`

_, _, interpretationError := suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, mainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, script, inputArgs, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask, defaultImageDownloadMode)
require.NotNil(suite.T(), interpretationError)
require.Equal(suite.T(), "Evaluation error: key \"arg1\" not in dict\n\tat [3:23]: run", interpretationError.GetErrorMessage())

scriptWithKwarg := `
def run(plan, arg0, args):
all_arg_values = arg0 + args["arg1"] + ":" + args["arg2"]
return all_arg_values
`
// however passing in kwargs, with args at the end is still fine
inputArgsWithKwarg := `{"arg0": "foo", "args": {"arg1": "arg1-value", "arg2": "arg2-value"}}`
_, _, interpretationError = suite.interpreter.Interpret(context.Background(), startosis_constants.PackageIdPlaceholderForStandaloneScript, mainFunctionName, noPackageReplaceOptions, startosis_constants.PlaceHolderMainFileForPlaceStandAloneScript, scriptWithKwarg, inputArgsWithKwarg, defaultNonBlockingMode, emptyEnclaveComponents, emptyInstructionsPlanMask, defaultImageDownloadMode)
require.Nil(suite.T(), interpretationError)
}

func (suite *StartosisInterpreterTestSuite) TestStartosisInterpreter_Test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const KurtosisPackageNode = memo(
// If args only has one record, and its value is args, ASSUME user is passing args via a JSON or YAML into the args object of def run(plan, args)
// via Json or Yaml editor
// If only an `args` object is provided, kurtosis will not interpret the value in the args object as passing args via the args dictionary is (technically) deprecated even though it's still allowed
if (Object.keys(args).length === 1 && args.hasOwnProperty('args')) {
args = args['args'] as Record<string, string> // TODO(tedi): ideally we'd validate and handle this in transform args utils
if (Object.keys(args).length === 1 && args.hasOwnProperty("args")) {
args = args["args"] as Record<string, string>; // TODO(tedi): ideally we'd validate and handle this in transform args utils
}

const plan = await kurtosisClient.getStarlarkPackagePlanYaml(
Expand Down

0 comments on commit 374f487

Please sign in to comment.