Skip to content

Commit

Permalink
tests(generate): fix existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Aug 27, 2024
1 parent f2fac5e commit f48ecf4
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/test_binary_generate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ proc main =
suite "generate":
const trackDir = testsDir / ".test_elixir_track_repo"
let generateCmd = &"{binaryPath} -t {trackDir} generate"
let generateCmdUpdate = &"{generateCmd} --update"
let generateCmdUpdateYes = &"{generateCmdUpdate} --yes"

# Setup: clone a track repo, and checkout a known state
setupExercismRepo("elixir", trackDir,
"91ccf91940f32aff3726c772695b2de167d8192a") # 2022-06-12

test "`configlet generate` exits with 0 when there are no `.md.tpl` files":
execAndCheck(0, generateCmd, "")
const expectedOutput = fmt"""
Every introduction file is up-to-date!
""".unindent().replace("\p", "\n")
execAndCheck(0, generateCmdUpdateYes, expectedOutput)

test "and does not make a change":
checkNoDiff(trackDir)
Expand All @@ -39,7 +44,7 @@ proc main =
removeIntro = false)

test "`configlet generate` exits with 1 for an invalid placeholder usage":
execAndCheckExitCode(1, generateCmd)
execAndCheckExitCode(1, generateCmdUpdateYes)

test "and does not make a change":
checkNoDiff(trackDir)
Expand All @@ -49,7 +54,11 @@ proc main =
removeIntro = true)

test "`configlet generate` exits with 0 for a valid `.md.tpl` file":
execAndCheck(0, generateCmd, "")
const expectedOutput = fmt"""
Outdated: {"exercises"/"concept"/"bird-count"/".docs"/"introduction.md"}
Generated 1 file
""".unindent().replace("\p", "\n")
execAndCheck(0, generateCmdUpdateYes, expectedOutput)

test "and writes the `introduction.md` file as expected":
checkNoDiff(trackDir)
Expand All @@ -59,7 +68,11 @@ proc main =
removeIntro = true)

test "`configlet generate` exits with 0 for valid placeholder usage with spaces":
execAndCheck(0, generateCmd, "")
const expectedOutput = fmt"""
Outdated: {"exercises"/"concept"/"bird-count"/".docs"/"introduction.md"}
Generated 1 file
""".unindent().replace("\p", "\n")
execAndCheck(0, generateCmdUpdateYes, expectedOutput)

test "and writes the `introduction.md` file as expected":
checkNoDiff(trackDir)
Expand Down

0 comments on commit f48ecf4

Please sign in to comment.