31 lines
853 B
Nim
31 lines
853 B
Nim
import std/[logging, paths]
|
|
import unittest
|
|
|
|
import ../../src/pathsd
|
|
|
|
suite "Test main() proc":
|
|
setup:
|
|
const fixturesPath = Path(currentSourcePath) / Path("..") / Path("..") / Path("fixtures")
|
|
const pathsdFixturePath = fixturesPath / Path("paths.d")
|
|
const expectedOutput = @["/Users/bilbo/opt/bin", "/opt/homebrew/bin", "/opt/homebrew/sbin"]
|
|
|
|
pathsd.logger.levelThreshold = lvlNone
|
|
|
|
test "Test happy path":
|
|
# When
|
|
var mainResult = pathsd.main(@[pathsdFixturePath.string])
|
|
|
|
# Then
|
|
check mainResult.output == expectedOutput
|
|
check mainResult.errorCode == QuitSuccess
|
|
|
|
test "Test skipping search paths that don't exist":
|
|
# When
|
|
var mainResult = pathsd.main(@[
|
|
pathsdFixturePath.string,
|
|
(fixturesPath / Path("idontexist")).string,
|
|
])
|
|
|
|
# Then
|
|
check mainResult.output == expectedOutput
|