tests for x_post
This commit is contained in:
parent
80e9fbb13d
commit
2ffa655163
@ -7,6 +7,7 @@ defmodule Bright.XPostTest do
|
||||
alias Bright.Platforms.{Platform, PlatformAlias}
|
||||
alias Bright.Platforms
|
||||
alias Bright.VultrAI
|
||||
alias Ecto.Query
|
||||
|
||||
@sample_feed "https://rss.app/feeds/FhPetvUY036xiFau.xml"
|
||||
|
||||
@ -35,38 +36,81 @@ defmodule Bright.XPostTest do
|
||||
end
|
||||
|
||||
describe "includes_alias?/2" do
|
||||
setup do
|
||||
ytmnd =
|
||||
%Platform{
|
||||
name: "You're The Man Now Dog",
|
||||
slug: "ytmnd",
|
||||
url: "https://blueballfixed.ytmnd.com",
|
||||
nsfw: false
|
||||
}
|
||||
|> Repo.insert!()
|
||||
|
||||
%PlatformAlias{url: "https://shorturl.at/lZ3NM", platform_id: ytmnd.id}
|
||||
|> Repo.insert!()
|
||||
|
||||
%Platform{name: "Twitch", slug: "twitch", url: "https://twitch.tv", nsfw: false}
|
||||
|> Repo.insert!()
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
@tag :unit
|
||||
test "returns true when a platform alias url is found in XPost raw content" do
|
||||
platform = %Platform{
|
||||
url: "https://blueballfixed.ytmnd.com",
|
||||
slug: "ytmnd",
|
||||
name: "You're The Man Now Dog",
|
||||
nsfw: false
|
||||
}
|
||||
|
||||
platform_alias = %PlatformAlias{url: "https://shorturl.at/lZ3NM", platform_id: platform.id}
|
||||
platform = Platform |> Repo.get_by!(slug: "ytmnd") |> Repo.preload(:platform_aliases)
|
||||
x_post = %XPost{raw: "Hello World please join my stream rn https://shorturl.at/lZ3NM"}
|
||||
assert XPost.includes_alias?(x_post, platform)
|
||||
end
|
||||
|
||||
@tag :unit
|
||||
test "returns false when no platform alias url is present in XPost raw content" do
|
||||
platform = Platform |> Repo.get_by!(slug: "ytmnd") |> Repo.preload(:platform_aliases)
|
||||
x_post = %XPost{raw: "i just ate breakfast and then i went outside it was gret"}
|
||||
assert not XPost.includes_alias?(x_post, platform)
|
||||
end
|
||||
|
||||
@tag :unit
|
||||
test "returns true when a platform alias url is found in raw_text" do
|
||||
platform = Platform |> Repo.get_by!(slug: "ytmnd") |> Repo.preload(:platform_aliases)
|
||||
raw_text = "GOING LIVE NOW shorturl.at/lZ3NM"
|
||||
assert XPost.includes_alias?(raw_text, platform)
|
||||
end
|
||||
|
||||
@tag :unit
|
||||
test "returns false when no platform alias url is present in raw_text" do
|
||||
platform = Platform |> Repo.get_by!(slug: "ytmnd") |> Repo.preload(:platform_aliases)
|
||||
raw_text = "#420 #blazeit #bbq #LuL"
|
||||
assert not XPost.includes_alias?(raw_text, platform)
|
||||
end
|
||||
end
|
||||
|
||||
describe "includes_platform?" do
|
||||
setup do
|
||||
%Platform{
|
||||
name: "Chaturbate",
|
||||
slug: "chaturbate",
|
||||
url: "https://chaturbate.com",
|
||||
nsfw: true
|
||||
}
|
||||
|> Repo.insert!()
|
||||
|
||||
%Platform{name: "Twitch", slug: "twitch", url: "https://twitch.tv", nsfw: false}
|
||||
|> Repo.insert!()
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
@tag :unit
|
||||
test "includes_platform? with raw text" do
|
||||
raw_text = "hello world check out my stream: twitch.tv/sexyman42"
|
||||
platform = %Platform{name: "Twitch", slug: "twitch", url: "https://twitch.tv", nsfw: false}
|
||||
raw_text = "hello world check out my stream: chaturbate.com/sexyman42"
|
||||
|
||||
platforms = Platform |> Repo.all()
|
||||
|
||||
platform =
|
||||
Platform
|
||||
|> Repo.get_by!(slug: "chaturbate")
|
||||
|> Repo.preload(:platform_aliases)
|
||||
|
||||
XPost.includes_platform?(raw_text, platform)
|
||||
end
|
||||
|
||||
@ -74,12 +118,10 @@ defmodule Bright.XPostTest do
|
||||
test "includes_platform? with x_post" do
|
||||
x_post = %XPost{raw: "LIVE NOW https://chaturbate.com"}
|
||||
|
||||
platform = %Platform{
|
||||
name: "Chaturbate",
|
||||
slug: "chaturbate",
|
||||
url: "https://chaturbate.com",
|
||||
nsfw: true
|
||||
}
|
||||
platform =
|
||||
Platform
|
||||
|> Repo.get_by!(slug: "chaturbate")
|
||||
|> Repo.preload(:platform_aliases)
|
||||
|
||||
XPost.includes_platform?(x_post, platform)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user