Add frontmatter, markdown, path, xml, rss, and web packages
Sync local packages into the registry repo and update index.json and README.md to include all 9 packages.
This commit is contained in:
106
packages/rss/test_integration.lux
Normal file
106
packages/rss/test_integration.lux
Normal file
@@ -0,0 +1,106 @@
|
||||
import lib
|
||||
|
||||
fn contains(haystack: String, needle: String): Bool =
|
||||
match String.indexOf(haystack, needle) {
|
||||
Some(_) => true,
|
||||
None => false,
|
||||
}
|
||||
|
||||
// Build a complete blog RSS feed with multiple posts
|
||||
fn test_full_blog_feed(): Unit with {Test} = {
|
||||
let items = [
|
||||
lib.item("Getting Started with Lux", "https://blog.example.com/getting-started", "Learn the basics of the Lux programming language", "2025-01-15"),
|
||||
lib.item("Advanced Effects in Lux", "https://blog.example.com/advanced-effects", "Deep dive into algebraic effects", "2025-02-01"),
|
||||
lib.item("Building a Static Site", "https://blog.example.com/static-site", "Create a blog with Lux", "2025-02-15")
|
||||
]
|
||||
let f = lib.feed("Lux Programming Blog", "https://blog.example.com", "Tips and tutorials about Lux", items)
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "<?xml version=\"1.0\""), "has XML declaration")
|
||||
Test.assert(contains(xml, "<rss version=\"2.0\""), "has RSS 2.0 tag")
|
||||
Test.assert(contains(xml, "<title>Lux Programming Blog</title>"), "feed title")
|
||||
Test.assert(contains(xml, "<link>https://blog.example.com</link>"), "feed link")
|
||||
Test.assert(contains(xml, "<title>Getting Started with Lux</title>"), "first item title")
|
||||
Test.assert(contains(xml, "<title>Advanced Effects in Lux</title>"), "second item title")
|
||||
Test.assert(contains(xml, "<title>Building a Static Site</title>"), "third item title")
|
||||
Test.assert(contains(xml, "15 Jan 2025 00:00:00 GMT"), "first item date in RFC 822")
|
||||
Test.assert(contains(xml, "01 Feb 2025 00:00:00 GMT"), "second item date in RFC 822")
|
||||
Test.assert(contains(xml, "<generator>Lux RSS Package</generator>"), "has generator tag")
|
||||
}
|
||||
|
||||
// Feed with items containing custom GUIDs
|
||||
fn test_feed_with_custom_guids(): Unit with {Test} = {
|
||||
let items = [
|
||||
lib.itemWithGuid("Post 1", "https://example.com/1", "Desc 1", "2025-01-01", "urn:uuid:1234"),
|
||||
lib.itemWithGuid("Post 2", "https://example.com/2", "Desc 2", "2025-02-01", "urn:uuid:5678")
|
||||
]
|
||||
let f = lib.feed("Blog", "https://example.com", "A blog", items)
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "urn:uuid:1234"), "first custom guid")
|
||||
Test.assert(contains(xml, "urn:uuid:5678"), "second custom guid")
|
||||
}
|
||||
|
||||
// Feed with special characters in all fields
|
||||
fn test_feed_with_special_chars(): Unit with {Test} = {
|
||||
let i = lib.item(
|
||||
"Tom & Jerry's <Adventure>",
|
||||
"https://example.com/tom&jerry",
|
||||
"A \"great\" show with <characters>",
|
||||
"2025-01-01"
|
||||
)
|
||||
let f = lib.feed(
|
||||
"Kids' TV & More",
|
||||
"https://example.com",
|
||||
"Shows for <everyone>",
|
||||
[i]
|
||||
)
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "&"), "ampersand escaped somewhere")
|
||||
Test.assert(contains(xml, "<"), "angle bracket escaped somewhere")
|
||||
}
|
||||
|
||||
// Multilingual feed
|
||||
fn test_multilingual_feed(): Unit with {Test} = {
|
||||
let f = lib.feedWithLang(
|
||||
"Mon Blog",
|
||||
"https://exemple.fr",
|
||||
"Un blog en francais",
|
||||
"fr",
|
||||
[lib.item("Premier Article", "https://exemple.fr/premier", "Le debut", "2025-01-01")]
|
||||
)
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "<language>fr</language>"), "french language tag")
|
||||
Test.assert(contains(xml, "<title>Premier Article</title>"), "french item title")
|
||||
}
|
||||
|
||||
// Empty feed is still valid XML
|
||||
fn test_empty_feed_structure(): Unit with {Test} = {
|
||||
let f = lib.feed("Empty Blog", "https://example.com", "Nothing here yet", [])
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "<?xml"), "has declaration")
|
||||
Test.assert(contains(xml, "<rss"), "has rss tag")
|
||||
Test.assert(contains(xml, "<channel>"), "has channel open")
|
||||
Test.assert(contains(xml, "</channel>"), "has channel close")
|
||||
Test.assert(contains(xml, "</rss>"), "has rss close")
|
||||
Test.assert(contains(xml, "<title>Empty Blog</title>"), "has title")
|
||||
}
|
||||
|
||||
// Feed with many items (stress test)
|
||||
fn test_feed_many_items(): Unit with {Test} = {
|
||||
let items = [
|
||||
lib.item("Post 1", "https://example.com/1", "D1", "2025-01-01"),
|
||||
lib.item("Post 2", "https://example.com/2", "D2", "2025-01-02"),
|
||||
lib.item("Post 3", "https://example.com/3", "D3", "2025-01-03"),
|
||||
lib.item("Post 4", "https://example.com/4", "D4", "2025-01-04"),
|
||||
lib.item("Post 5", "https://example.com/5", "D5", "2025-01-05"),
|
||||
lib.item("Post 6", "https://example.com/6", "D6", "2025-01-06"),
|
||||
lib.item("Post 7", "https://example.com/7", "D7", "2025-01-07"),
|
||||
lib.item("Post 8", "https://example.com/8", "D8", "2025-01-08"),
|
||||
lib.item("Post 9", "https://example.com/9", "D9", "2025-01-09"),
|
||||
lib.item("Post 10", "https://example.com/10", "D10", "2025-01-10")
|
||||
]
|
||||
let f = lib.feed("Big Blog", "https://example.com", "Many posts", items)
|
||||
let xml = lib.render(f)
|
||||
Test.assert(contains(xml, "<title>Post 1</title>"), "first item")
|
||||
Test.assert(contains(xml, "<title>Post 10</title>"), "last item")
|
||||
Test.assert(contains(xml, "10 Jan 2025"), "last item date")
|
||||
}
|
||||
Reference in New Issue
Block a user