From 78412a40a139e8a86bf3c5854b98b80ff54c1b0d Mon Sep 17 00:00:00 2001 From: Able <abl3theabove@gmail.com> Date: Tue, 18 Feb 2025 14:27:12 -0600 Subject: [PATCH] TEST: Attempt at making a test --- lib/templating.ex | 17 +++++++++++++++++ test/rl_repo_test.exs | 13 +++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/templating.ex b/lib/templating.ex index 267acb4..5a2f89d 100644 --- a/lib/templating.ex +++ b/lib/templating.ex @@ -19,6 +19,23 @@ defmodule RlRepo.Template do # body end + def test_template(template_name, replacements) do + body = "~(reason)" + # TODO: Check if there is any actual placeholders + v = String.contains?(body, "~(") + Logger.info v + # if v do + len = body |> String.split("~(") |> length() + Logger.info body + # TODO: Math this out to be equal to the number of splits + # if len >= 2 do + template_step(replacements, body, len) + # Logger.info "Len greater 2" + # end + # end + # body + end + def template_step(replacements, body, steps_left) do [before_placeholder | rest] = split_path = String.split(body, "~(", parts: 2) [remains | _] = rest diff --git a/test/rl_repo_test.exs b/test/rl_repo_test.exs index fa599e3..c248b2e 100644 --- a/test/rl_repo_test.exs +++ b/test/rl_repo_test.exs @@ -1,8 +1,17 @@ defmodule RlRepoTest do + require Logger use ExUnit.Case doctest RlRepo - test "greets the world" do - # assert RlRepo.hello() == :world + test "single template replace" do + string = "~(replace)" + placeholders = %{"replace" => "DONE"} + + + + b = RlRepo.Template.test_template(string, placeholders) + + + assert :world == :world end end