Skip to content

Commit

Permalink
tests: split aliases tests into smaller ones
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 357df704d7018c66540f09a2bd0d7ae89170671cedffb15b71330db87f420a30
  • Loading branch information
thindil committed May 22, 2024
1 parent 8782290 commit 8c3917f
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tests/aliases.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,50 +46,52 @@ suite "Unit tests for aliases module":
check:
myaliases.len == 1

test "Getting the shell's alias ID":
checkpoint "Getting ID of an existing alias"
test "Getting ID of an existing alias":
check:
getAliasId(arguments = "delete 2", db = db).int == 2
checkpoint "Getting ID of a non-existing alias"

test "Getting ID of a non-existing alias":
check:
getAliasId(arguments = "delete 22", db = db).int == 0

test "Deleting the shell's alias":
checkpoint "Deleting an existing alias"
test "Deleting an existing alias":
check:
deleteAlias(arguments = "delete 2", aliases = myaliases, db = db) == QuitSuccess
db.count(T = Alias) == 1
checkpoint "Deleting a non-existing alias"

test "Deleting a non-existing alias":
check:
deleteAlias(arguments = "delete 22", aliases = myaliases, db = db) == QuitFailure
checkpoint "Re-adding the test alias"

test "Re-adding the test alias":
var testAlias2: Alias = newAlias(name = "tests2", path = "/".Path,
recursive = false,
commands = "ls -a", description = "Test alias 2.", output = "output")
db.insert(obj = testAlias2)
unittest2.require:
db.count(T = Alias) == 2

test "Setting the shell's aliases in the current directory":
test "Checking an existing alias":
myaliases.setAliases(directory = paths.getCurrentDir(), db = db)
checkpoint "Checking an existing alias"
check:
execAlias(arguments = "", aliasId = "tests", aliases = myaliases,
db = db) == QuitSuccess
checkpoint "Checking a non existing alias"

test "Checking a non existing alias":
check:
execAlias(arguments = "", aliasId = "tests2", aliases = myaliases,
db = db) == QuitFailure

test "Listing the shell's aliases":
checkpoint "List the shell's aliases in the current directory"
test "List the shell's aliases in the current directory":
check:
db.count(T = Alias) == 2
listAliases(arguments = "list", aliases = myaliases, db = db) == QuitSuccess
checkpoint "List all available the shell aliases"

test "List all available the shell aliases":
check:
listAliases(arguments = "list all", aliases = myaliases, db = db) == QuitSuccess
checkpoint "Check what happen when invalid argument passed to listAliases"

test "Check what happen when invalid argument passed to listAliases":
expect PreConditionDefect:
check:
listAliases(arguments = "werwerew", aliases = myaliases, db = db) == QuitSuccess
Expand Down

0 comments on commit 8c3917f

Please sign in to comment.