More flakey tests

This commit is contained in:
Kieran Eglin 2024-05-08 09:44:02 -07:00
parent b5e306f6a8
commit f13122b36e
No known key found for this signature in database
GPG key ID: 193984967FCF432D
5 changed files with 18 additions and 5 deletions

View file

@ -18,7 +18,9 @@
</div> </div>
<div class="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear"> <div class="no-scrollbar flex flex-col overflow-y-auto duration-300 ease-linear">
<nav class="mt-3 px-4 py-4 lg:px-6"> <nav class="mt-3 px-4 py-4 lg:px-6">
<h3 class="mb-4 ml-4 text-sm font-medium text-bodydark2">MENU</h3> <h3 class="mb-4 ml-4 text-sm font-medium text-bodydark2">
<span>MENU</span>
</h3>
<div class="flex flex-col justify-between"> <div class="flex flex-col justify-between">
<ul class="mb-6 flex flex-col gap-1.5"> <ul class="mb-6 flex flex-col gap-1.5">
<.sidebar_item icon="hero-home" text="Home" href={~p"/"} /> <.sidebar_item icon="hero-home" text="Home" href={~p"/"} />

View file

@ -15,11 +15,12 @@ defmodule Pinchflat.Lifecycle.UserScripts.CommandRunnerTest do
test "runs the provided lifecycle file if present" do test "runs the provided lifecycle file if present" do
# We *love* indirectly testing side effects # We *love* indirectly testing side effects
tmp_dir = Application.get_env(:pinchflat, :tmpfile_directory) tmp_dir = Application.get_env(:pinchflat, :tmpfile_directory)
File.write(filepath(), "#!/bin/bash\ntouch #{tmp_dir}/test_file\n") filename = "#{tmp_dir}/test_file-#{Enum.random(1..1000)}"
File.write(filepath(), "#!/bin/bash\ntouch #{filename}\n")
refute File.exists?("#{tmp_dir}/test_file") refute File.exists?(filename)
assert :ok = Runner.run(:media_downloaded, %{}) assert :ok = Runner.run(:media_downloaded, %{})
assert File.exists?("#{tmp_dir}/test_file") assert File.exists?(filename)
end end
test "passes the event name to the script" do test "passes the event name to the script" do

View file

@ -41,7 +41,7 @@ defmodule PinchflatWeb.MediaProfileControllerTest do
Settings.set(onboarding: true) Settings.set(onboarding: true)
conn = get(conn, ~p"/media_profiles/new") conn = get(conn, ~p"/media_profiles/new")
refute html_response(conn, 200) =~ "MENU" refute html_response(conn, 200) =~ "<span>MENU</span>"
end end
end end

View file

@ -15,6 +15,7 @@ defmodule Pinchflat.DataCase do
""" """
use ExUnit.CaseTemplate use ExUnit.CaseTemplate
alias Pinchflat.TestingHelperMethods
using do using do
quote do quote do
@ -32,6 +33,8 @@ defmodule Pinchflat.DataCase do
setup tags do setup tags do
Pinchflat.DataCase.setup_sandbox(tags) Pinchflat.DataCase.setup_sandbox(tags)
TestingHelperMethods.create_platform_directories()
:ok :ok
end end

View file

@ -54,4 +54,11 @@ defmodule Pinchflat.TestingHelperMethods do
|> render_metadata() |> render_metadata()
|> Phoenix.json_library().decode!() |> Phoenix.json_library().decode!()
end end
def create_platform_directories do
File.mkdir_p!(Application.get_env(:pinchflat, :media_directory))
File.mkdir_p!(Application.get_env(:pinchflat, :metadata_directory))
File.mkdir_p!(Application.get_env(:pinchflat, :extras_directory))
File.mkdir_p!(Application.get_env(:pinchflat, :tmpfile_directory))
end
end end