Closed
Description
Introduction
When building sqlpage 0.26.0 from source, the test "/tests/sql_test_files/it_works_fetch_post.sql?x=1" failed.
So I can't build sqlpage from source.
To Reproduce
Build from source 0.26.0 on nixos from my branch :
https://github.com/guiguid/nixpkgs/blob/guiguid-patch-sqlpage-0.26.0/pkgs/servers/sqlpage/default.nix
# on NixOS, or with nix installed
git clone --depth 2 --branch guiguid-patch-sqlpage-0.26.0 [email protected]:guiguid/nixpkgs.git ./mynixpkgs
export NIXPKGS=/path/to/mynixpkgs/
nix-build $NIXPKGS -A sqlpage
Actual behavior
Running tests/index.rs (target/x86_64-unknown-linux-gnu/release/deps/index-f9dc0dd78f80e231)
running 18 tests
test privileged_paths_are_not_accessible ... ok
test test_file_upload_through_runsql ... ok
test test_file_upload_direct ... ok
test test_blank_file_upload_field ... ok
test test_access_config_forbidden ... ok
test test_csv_upload ... ok
test test_file_upload_too_large ... ok
test test_index_ok ... ok
test test_overwrite_variable ... ok
test test_static_files ... ok
test test_404 ... ok
test test_official_website_basic_auth_example ... ok
test test_upload_file_data_url ... ok
test test_files ... FAILED
test test_official_website_documentation ... ok
test test_uploaded_file_name ... ok
test test_with_site_prefix ... ok
test test_concurrent_requests ... ok
failures:
---- test_files stdout ----
[2024-08-16T16:49:17Z ERROR sqlpage::render] SQL error: The cookie component cannot be used after data has already been sent to the client's browser. This component must be used before any other component. To fix this, either move the call to the 'cookie' component to the top of the SQL file, or create a new SQL file where 'cookie' is the first component.
thread 'test_files' panicked at tests/index.rs:158:13:
/tests/sql_test_files/it_works_fetch_post.sql?x=1
<!DOCTYPE html>
<html lang="" style="font-size: 18px" >
<head>
<meta charset="utf-8"/>
<title>SQLPage</title>
<link rel="icon" href="/favicon.1e1ed7768914d0a1.svg">
<link rel="stylesheet" href="/sqlpage.ccb9a1a684c8574f.css">
<script src="/sqlpage.225162e5eced1dda.js" defer nonce="17375914365177344597"></script>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content=""/>
<meta name="generator" content="SQLPage"/>
</head>
<body class="layout-boxed" >
<div class="page">
<main class="page-wrapper container-xl pt-3 px-md-5 px-sm-3 " id="sqlpage_main_wrapper"><div class="alert alert-danger text-muted mt-2" role="alert">
<p>
<span class="status status-red">
<span class="status-dot status-dot-animated"></span> Error
</span>
We are sorry, but an error occurred while generating this page.
You should contact the site's administrator.
</p>
<p>
</p>
<pre><code>Failed to set the $res variable to StmtWithParams { query: "SELECT CAST(? AS TEXT)", params: [FunctionCall(SqlPageFunctionCall { function: fetch, arguments: [Literal("{\n \"method\": \"POST\",\n \"url\": \"http://localhost:62802/post\",\n \"headers\": {\"x-custom\": \"1\"},\n \"body\": {\"hello\": \"world\"}\n}")] })], delayed_functions: [] }</code></pre>
<details open class="fs-5">
<summary>Backtrace</summary><pre class="fs-5 mt-1 p-1 my-1"><code>Error in function call sqlpage.fetch('{
"method": "POST",
"url": "http://localhost:62802/post",
"headers": {"x-custom": "1"},
"body": {"hello": "world"}
}').
Expected sqlpage.fetch(http_request)</code></pre><pre class="fs-5 mt-1 p-1 my-1"><code>No such file or directory (os error 2)</code></pre></details>
</div>
</main>
</div>
<footer class="w-100 text-center fs-6 my-2 text-secondary" id="sqlpage_footer">
<!-- You can change this footer using the 'footer' parameter of the 'shell' component -->
Built with <a class="text-reset" href="https://sql.ophir.dev" title="SQLPage v0.26.0">SQLPage</a>
</footer>
</body>
</html>
expected to contain: It works !
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
test_files
test result: FAILED. 17 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.44s
Expected behavior
The build of SQLPage 0.25.0 works passing all tests
Running tests/index.rs (target/x86_64-unknown-linux-gnu/release/deps/index-059546e3b8f19476)
running 18 tests
test privileged_paths_are_not_accessible ... ok
test test_access_config_forbidden ... ok
test test_blank_file_upload_field ... ok
test test_file_upload_through_runsql ... ok
test test_csv_upload ... ok
test test_file_upload_direct ... ok
test test_file_upload_too_large ... ok
test test_index_ok ... ok
test test_overwrite_variable ... ok
test test_404 ... ok
test test_static_files ... ok
test test_uploaded_file_name ... ok
test test_official_website_basic_auth_example ... ok
test test_upload_file_data_url ... ok
test test_official_website_documentation ... ok
test test_with_site_prefix ... ok
test test_files ... ok
test test_concurrent_requests ... ok
test result: ok. 18 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.44s
Version information
- OS: NixOS 24.05.3407.12bf09802d77
- Database [e.g. SQLite, Postgres] /
- SQLPage Version : 0.26.0