* Return array of results duckdb * Migration script to add result_collection=legacy * migration script fixes * app_version_lite not necessary * New annotations macro that supports custom types * pass unit tests * nit style * result_collection almost works for postgres * fix last_statement * frontend suggesitons * fix column_order making columns disappear * added version check for duckdb FFI lib to avoid crashes when changing FFI interface on Windows agent workers * result_collection for duckdb * Correct legacy behavior in DuckDB * mysql result_collection * mssql collection_strategy * result_collection for oracle * snowflake result_collection * fix errors * mistake, .clone() causing deadlock * fix frontend errors on oracle / mssql * fix legacy behavior on mssql * add exception catch in migration * missing app_script update * change cache layout to avoid worker pulling old scripts
170 lines
4.5 KiB
Rust
170 lines
4.5 KiB
Rust
#[cfg(test)]
|
|
mod annotations_tests {
|
|
|
|
extern crate windmill_macros;
|
|
use itertools::Itertools;
|
|
use windmill_macros::annotations;
|
|
|
|
// Previous implementation.
|
|
// We have to make sure that new one works the same as old one
|
|
fn old(inner_content: &str) -> Annotations {
|
|
let annotations = inner_content
|
|
.lines()
|
|
.take_while(|x| x.starts_with("#"))
|
|
.map(|x| x.to_string().replace("#", "").trim().to_string())
|
|
.collect_vec();
|
|
|
|
let ann1: bool = annotations.contains(&"ann1".to_string());
|
|
let ann2: bool = annotations.contains(&"ann2".to_string());
|
|
let ann3: bool = annotations.contains(&"ann3".to_string());
|
|
let ann4: bool = annotations.contains(&"ann4".to_string());
|
|
let ann5: bool = annotations.contains(&"ann5".to_string());
|
|
|
|
Annotations { ann1, ann2, ann3, ann4, ann5 }
|
|
}
|
|
|
|
#[annotations("#")]
|
|
#[derive(Eq, PartialEq)]
|
|
pub struct Annotations {
|
|
pub ann1: bool,
|
|
pub ann2: bool,
|
|
pub ann3: bool,
|
|
pub ann4: bool,
|
|
pub ann5: bool,
|
|
}
|
|
|
|
#[annotations("//")]
|
|
#[derive(Eq, PartialEq)]
|
|
pub struct SlashedAnnotations {
|
|
pub ann1: bool,
|
|
pub ann2: bool,
|
|
pub ann3: bool,
|
|
pub ann4: bool,
|
|
}
|
|
|
|
#[annotations("--")]
|
|
#[derive(Eq, PartialEq)]
|
|
pub struct MinusedAnnotations {
|
|
pub ann1: bool,
|
|
pub ann2: bool,
|
|
}
|
|
|
|
// e.g. rust, TS and JS
|
|
#[test]
|
|
fn slashed_annotations() {
|
|
let cont = "// ann1
|
|
// ann2
|
|
//ann3";
|
|
assert_eq!(
|
|
SlashedAnnotations { ann1: true, ann2: true, ann3: true, ann4: false },
|
|
SlashedAnnotations::parse(cont)
|
|
);
|
|
}
|
|
|
|
// e.g. Haskell, SQL
|
|
#[test]
|
|
fn minused_annotations() {
|
|
let cont = "-- ann1
|
|
-- ann2";
|
|
assert_eq!(
|
|
MinusedAnnotations { ann1: true, ann2: true },
|
|
MinusedAnnotations::parse(cont)
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn simple_integration() {
|
|
let cont = "# ann1";
|
|
let expected = Annotations { ann1: true, ..Default::default() };
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
|
|
#[test]
|
|
fn multiline_integration() {
|
|
let cont = "# ann2
|
|
# ann3
|
|
# ann4
|
|
# ann5
|
|
";
|
|
let expected = Annotations {
|
|
ann1: false,
|
|
ann2: true,
|
|
ann3: true,
|
|
ann4: true,
|
|
ann5: true,
|
|
//
|
|
};
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
|
|
#[test]
|
|
fn spacing_integration() {
|
|
// First line is ignored and not used
|
|
{
|
|
let cont = "
|
|
# ann2";
|
|
let expected = Annotations { ..Default::default() };
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
// Wrong spacing for ann3
|
|
{
|
|
let cont = "# ann2
|
|
# ann3";
|
|
|
|
let expected = Annotations { ann2: true, ..Default::default() };
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
|
|
// Drunk but valid spacing
|
|
{
|
|
let cont = "#ann1
|
|
# ann2";
|
|
let expected = Annotations { ann2: true, ann1: true, ..Default::default() };
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn comments_inbetween_integration() {
|
|
let cont = "# ann2
|
|
# Just comment, has nothing to do with annotations
|
|
# Another comment: ann1 ann2 ann3
|
|
# ann4 is not valid annotation
|
|
# Actual annotation next line:
|
|
# ann5
|
|
|
|
# Should be ignored
|
|
# ann3
|
|
";
|
|
let expected = Annotations { ann2: true, ann5: true, ..Default::default() };
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
|
|
#[test]
|
|
fn hash_collision() {
|
|
// TODO
|
|
}
|
|
#[test]
|
|
fn non_matching_integration() {
|
|
{
|
|
let cont = r#" "ann1", ann2 "#;
|
|
let expected = Annotations::default();
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
// Empty
|
|
{
|
|
let cont = "";
|
|
let expected = Annotations::default();
|
|
assert_eq!(expected, old(cont));
|
|
assert_eq!(expected, Annotations::parse(cont));
|
|
}
|
|
}
|
|
}
|