mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
test: Fixed scan_test.
This commit is contained in:
2
TODOS.md
2
TODOS.md
@@ -24,8 +24,6 @@
|
||||
|
||||
16. Add tests for untested commands.
|
||||
|
||||
17. 2 scan tests silently skip when fd isn't installed, tests pass without actually testing anything. These should use #assert to be sure that fd is in path.
|
||||
|
||||
18. add --format -f flag to commands that draw tables.
|
||||
|
||||
19. Replace `testing.expect` calls with `testing.expect_value` calls where appropriate.
|
||||
|
||||
@@ -19,20 +19,23 @@ test_scan_path_finds_gitignored_env_files :: proc(t: ^testing.T) {
|
||||
stderr = os.stderr,
|
||||
}
|
||||
p, err := os.process_start(git_init)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, wait_err := os.process_wait(p)
|
||||
if wait_err != nil {
|
||||
return
|
||||
}
|
||||
testing.expectf(t, err == nil, "Failed to run git: %v", err)
|
||||
if err != nil do return
|
||||
state, wait_err := os.process_wait(p)
|
||||
testing.expectf(t, wait_err == nil, "Failed to wait: %v", wait_err)
|
||||
if wait_err != nil do return
|
||||
testing.expect(t, state.success, "command should succeed")
|
||||
|
||||
gitignore_path := fmt.tprintf("%s/.gitignore", base)
|
||||
_ = os.write_entire_file(gitignore_path, ".env*\n")
|
||||
err = os.write_entire_file(gitignore_path, ".env*\n")
|
||||
testing.expectf(t, err == nil, "Failed: %v", err)
|
||||
|
||||
_ = os.write_entire_file(fmt.tprintf("%s/.env", base), "SECRET=1")
|
||||
_ = os.write_entire_file(fmt.tprintf("%s/.env.testing", base), "TEST=1")
|
||||
_ = os.write_entire_file(fmt.tprintf("%s/config.yaml", base), "key: value")
|
||||
err = os.write_entire_file(fmt.tprintf("%s/.env", base), "SECRET=1")
|
||||
testing.expectf(t, err == nil, "Failed: %v", err)
|
||||
err = os.write_entire_file(fmt.tprintf("%s/.env.testing", base), "TEST=1")
|
||||
testing.expectf(t, err == nil, "Failed: %v", err)
|
||||
err = os.write_entire_file(fmt.tprintf("%s/config.yaml", base), "key: value")
|
||||
testing.expectf(t, err == nil, "Failed: %v", err)
|
||||
|
||||
cfg := Config {
|
||||
scan_config = ScanConfig{matcher = "\\.env"},
|
||||
|
||||
Reference in New Issue
Block a user