34 lines
		
	
	
		
			671 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			671 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
# -*- mode: sh -*-
 | 
						|
 | 
						|
function initDirenv {
 | 
						|
    # direnv needs a writable home:
 | 
						|
    run "export HOME=$(pwd)"
 | 
						|
    run 'eval "$(direnv hook bash)"'
 | 
						|
}
 | 
						|
 | 
						|
function test_simpleEnvrcWorks {
 | 
						|
    initDirenv
 | 
						|
 | 
						|
    writeFile .envrc <<EOF
 | 
						|
          export FOO=bar
 | 
						|
EOF
 | 
						|
    run "direnv allow"
 | 
						|
    assert "$(getEnv FOO)" == bar
 | 
						|
}
 | 
						|
 | 
						|
function test_direnvExecRunsInCleanEnv {
 | 
						|
    initDirenv
 | 
						|
 | 
						|
    run "export FOO=baz"
 | 
						|
 | 
						|
    writeFile .envrc <<EOF
 | 
						|
          export FOO=bar
 | 
						|
EOF
 | 
						|
 | 
						|
    run "direnv allow"
 | 
						|
    assert "$(getEnv FOO)" == bar
 | 
						|
    #captureShell 'echo $FOO'
 | 
						|
    #captureShell 'direnv exec /proc env | grep FOO'
 | 
						|
    assert "$(captureShell 'direnv exec /proc env | grep FOO')" == "FOO=baz"
 | 
						|
}
 |