35 lines
1.5 KiB
Elixir
35 lines
1.5 KiB
Elixir
defmodule HttpTest do
|
|
use ExUnit.Case
|
|
doctest ElixirRss
|
|
|
|
test "fetch url" do
|
|
assert ElixirRss.Fetcher.fetch("https://shillerben.com") |> elem(0) == :ok
|
|
end
|
|
|
|
test "parse RSS to model" do
|
|
items = File.read("test/slashdotMain.xml")
|
|
|> elem(1)
|
|
|> ElixirRss.Fetcher.parse_rss_to_model()
|
|
first = Enum.at(items, 0)
|
|
assert Map.keys(first) == ["description", "title"]
|
|
titles = Enum.map(items, &(Map.get(&1, "title")))
|
|
assert titles == [
|
|
"North Carolina Maker of High-Purity Quartz Back Operating After Hurricane",
|
|
"California Newspaper Creates AI-Powered 'News Assistant' for Kamala Harris Info",
|
|
"Microsoft's Take On Kernel Access and Safe Deployment After CrowdStrike Incident",
|
|
"Who's Winning America's 'Tech War' With China?",
|
|
"The Radio-Obsessed Civilian Shaping Ukraine's Drone Defense",
|
|
"AI Disclaimers in Political Ads Backfire on Candidates, Study Finds",
|
|
"Halcyon Announces Anti-Ransomware Protection for Enterprise Linux Environments",
|
|
"Amazon Expands Same-Day Prescription Delivery to Nearly Half the US Next Year",
|
|
"'Running Clang in the Browser Using WebAssembly'",
|
|
"Boeing Plans to Cut 17,000 Jobs - 10% of Its Workforce",
|
|
"PC Shipments Stuck in Neutral Despite AI Buzz",
|
|
"Imgur Is No Longer Classifying Memes With Adult Humor As Mature",
|
|
"NASA Confirms Plans To Develop Lunar Time Standard",
|
|
"The Crackdown on Compounded GLP-1 Meds Has Begun",
|
|
"Physicists Generated Sound Waves That Travel In One Direction Only",
|
|
]
|
|
end
|
|
end
|