Skip to content

Commit

Permalink
test: add json string plan opts tests (#1259)
Browse files Browse the repository at this point in the history
* test: add json string plan opts tests

Signed-off-by: peefy <[email protected]>

* chore: remove daily release CI

Signed-off-by: peefy <[email protected]>

---------

Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy authored Apr 29, 2024
1 parent bb416e9 commit eeda831
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 141 deletions.
134 changes: 0 additions & 134 deletions .github/workflows/daily-release.yaml

This file was deleted.

36 changes: 29 additions & 7 deletions kclvm/runtime/src/value/val_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,43 +352,65 @@ mod test_value_plan {
config.dict_update_key_value("_hidden", ValueRef::int(1));
config.dict_update_key_value("vec", ValueRef::list(None));
config.dict_update_key_value("empty", ValueRef::none());
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(json_string, "{\"data\": {}, \"vec\": [], \"empty\": null}");
assert_eq!(yaml_string, "data: {}\nvec: []\nempty: null");

ctx.plan_opts.include_schema_type_path = true;
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(
json_string,
"{\"data\": {\"_type\": \"__main__.Data\"}, \"vec\": [], \"empty\": null}"
);
assert_eq!(
yaml_string,
"data:\n _type: __main__.Data\nvec: []\nempty: null"
);

ctx.plan_opts.show_hidden = true;
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(
json_string,
"{\"data\": {\"_type\": \"__main__.Data\"}, \"_hidden\": 1, \"vec\": [], \"empty\": null}"
);
assert_eq!(
yaml_string,
"data:\n _type: __main__.Data\n_hidden: 1\nvec: []\nempty: null"
);

ctx.plan_opts.sort_keys = true;
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(
json_string,
"{\"_hidden\": 1, \"data\": {\"_type\": \"__main__.Data\"}, \"empty\": null, \"vec\": []}"
);
assert_eq!(
yaml_string,
"_hidden: 1\ndata:\n _type: __main__.Data\nempty: null\nvec: []"
);

ctx.plan_opts.disable_none = true;
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(
json_string,
"{\"_hidden\": 1, \"data\": {\"_type\": \"__main__.Data\"}, \"vec\": []}"
);
assert_eq!(
yaml_string,
"_hidden: 1\ndata:\n _type: __main__.Data\nvec: []"
);

ctx.plan_opts.disable_empty_list = true;
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(
json_string,
"{\"_hidden\": 1, \"data\": {\"_type\": \"__main__.Data\"}}"
);
assert_eq!(yaml_string, "_hidden: 1\ndata:\n _type: __main__.Data");

ctx.plan_opts.query_paths = vec!["data".to_string()];
let (_, yaml_string) = config.plan(&ctx);
let (json_string, yaml_string) = config.plan(&ctx);
assert_eq!(json_string, "{}");
assert_eq!(yaml_string, "{}");
}
}

0 comments on commit eeda831

Please sign in to comment.