]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/autoenv.t
8d2e864c5bff970bb7bb180b9f09919a5a7ad957
[zsh-autoenv.git] / tests / autoenv.t
1   $ source $TESTDIR/setup.zsh || return 1
2
3 Lets set a simple .autoenv.zsh action
4
5   $ echo 'echo ENTERED' > .autoenv.zsh
6
7 Manually create auth file
8
9   $ test_autoenv_add_to_env $PWD/.autoenv.zsh
10   $ cd .
11   ENTERED
12
13 Now try to make it accept it
14
15   $ _autoenv_stack_entered=()
16   $ rm $AUTOENV_AUTH_FILE
17   $ _autoenv_ask_for_yes() { echo "yes" }
18   $ cd .
19   Attempting to load unauthorized env file!
20   -* /*/cramtests-*/autoenv.t/.autoenv.zsh (glob)
21   
22   **********************************************
23   
24   echo ENTERED
25   
26   **********************************************
27   
28   Would you like to authorize it? (type 'yes') yes
29   ENTERED
30
31
32 The last "ENTERED" is because it executed the command.
33
34 Now lets see that it actually checks the shasum value.
35
36   $ _autoenv_stack_entered=()
37   $ cd .
38   ENTERED
39
40   $ _autoenv_stack_entered=()
41   $ rm $AUTOENV_AUTH_FILE
42   $ test_autoenv_add_to_env $PWD/.autoenv.zsh mischief
43   $ cd .
44   Attempting to load unauthorized env file!
45   -* /*/cramtests-*/autoenv.t/.autoenv.zsh (glob)
46   
47   **********************************************
48   
49   echo ENTERED
50   
51   **********************************************
52   
53   Would you like to authorize it? (type 'yes') yes
54   ENTERED
55
56
57 Now, will it take no for an answer?
58
59   $ _autoenv_stack_entered=()
60   $ rm $AUTOENV_AUTH_FILE
61   $ _autoenv_ask_for_yes() { echo "no"; return 1 }
62   $ cd .
63   Attempting to load unauthorized env file!
64   -* /*/cramtests-*/autoenv.t/.autoenv.zsh (glob)
65   
66   **********************************************
67   
68   echo ENTERED
69   
70   **********************************************
71   
72   Would you like to authorize it? (type 'yes') no
73
74
75 Lets also try one more time to ensure it didn't add it.
76
77   $ _autoenv_ask_for_yes() { echo "yes"; return 0 }
78   $ cd .
79   Attempting to load unauthorized env file!
80   -* /*/cramtests-*/autoenv.t/.autoenv.zsh (glob)
81   
82   **********************************************
83   
84   echo ENTERED
85   
86   **********************************************
87   
88   Would you like to authorize it? (type 'yes') yes
89   ENTERED
90
91 Reloading the script should keep the current state, e.g. when reloading your
92 ~/.zshrc.
93
94   $ $TEST_SOURCE_AUTOENV
95   $ cd .