ext/web W4: Postgres, Redis/memory cache, and S3/file storage drivers

URL-scheme backends keep the same # db CRUD author API; add # cache and

Co-authored-by: Cursor <cursoragent@cursor.com>
# storage with offline memory:/file: gold coverage.
This commit is contained in:
cflmy committed 2026-08-28 10:33:05 +08:00
1 parent e7c9c21a49
commit 034f52b7e7
14 files changed
+2504 -17

No files matched your search

+72
View File
@@ -0,0 +1,72 @@
---
title: web drivers smoke (W4)
description: memory cache + file storage + postgres URL shape (offline).
import web:ext/web/web.mq.md
import plugin:lib/plugin.mq.md
import sys:lib/sys.mq.md
---
# main
*p = > plugin.native_path name="web"*
1. `p`
> plugin.load path=`p`
2. *
> sys.exit code=1
<!-- cache: memory backend -->
*c = > web.cache url="memory:drivers-smoke"*
> `c`.set key="k1" value="v1" ttl=60
*g = > `c`.get key="k1"*
*gv = g[^value]*
1. `gv` == "v1"
> print text=cache-ok
2. *
> print text=cache-fail
> `c`.del key="k1"
*ex = > `c`.exists key="k1"*
*eok = ex[^ok]*
1. `eok`
> print text=cache-del-fail
2. *
> print text=cache-del-ok
<!-- storage: file backend -->
*blob = > web.storage url="file:tests/ext/web-fixtures/data/drivers-blobs"*
> `blob`.put key="notes/a.txt" body="hello" content_type="text/plain"
*got = > `blob`.get key="notes/a.txt"*
*body = got[^body]*
1. `body` == "hello"
> print text=storage-ok
2. *
> print text=storage-fail
*ls = > `blob`.list prefix="notes/"*
*n = ls[^count]*
1. `n` == 1
> print text=storage-list-ok
2. *
> print text=storage-list-fail
> `blob`.delete key="notes/a.txt"
<!-- db: postgres URL is accepted as a handle (no live server required) -->
*pg = > web.db url="postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"*
*purl = pg[^url]*
1. `purl` == "postgres://marqdo:marqdo@127.0.0.1:5432/marqdo"
> print text=postgres-url-ok
2. *
> print text=postgres-url-fail
<!-- s3 URL shape validates at open -->
*s3 = > web.storage url="s3://bucket?endpoint=http://127.0.0.1:9000"*
*sb = s3[^backend]*
1. `sb` == "s3"
> print text=s3-open-ok
2. *
> print text=s3-open-fail
+25
View File
@@ -1740,6 +1740,31 @@ rss-ok",
);
}
#[test]
fn ext_web_drivers_smoke() {
// W4 drivers: memory cache, file storage, postgres/s3 URL shape (offline).
let status = Command::new("cargo")
.args(["build", "-p", "marqdo_plugin_web"])
.current_dir(env!("CARGO_MANIFEST_DIR"))
.status()
.expect("build web plugin");
assert!(status.success(), "failed to build marqdo_plugin_web");
let root = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/ext/web-fixtures/data/drivers-blobs");
let _ = std::fs::remove_dir_all(&root);
assert_out(
"tests/ext/web-drivers-smoke.mq.md",
"cache-ok
cache-del-ok
storage-ok
storage-list-ok
postgres-url-ok
s3-open-ok",
);
}
#[test]
fn ext_web_db_w2_smoke() {
// W2 data layer: transactions, connection pooling, pagination, query