]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/autoenv.t
Improve interactive prompt
[zsh-autoenv.git] / tests / autoenv.t
1   $ source $TESTDIR/setup.sh
2
3 Lets set a simple .env action
4
5   $ echo 'echo ENTERED' >> .env
6
7 Manually create auth file
8
9   $ test_autoenv_add_to_env $PWD/.env
10   $ cd .
11   ENTERED
12
13 Now try to make it accept it
14
15   $ unset _autoenv_stack_entered
16   $ rm $AUTOENV_ENV_FILENAME
17   $ _autoenv_ask_for_yes() { echo "yes" }
18   $ cd .
19   Attempting to load unauthorized env file!
20   -* /tmp/cramtests-*/autoenv.t/.env (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   $ unset _autoenv_stack_entered
37   $ cd .
38   ENTERED
39
40   $ unset _autoenv_stack_entered
41   $ rm $AUTOENV_ENV_FILENAME
42   $ test_autoenv_add_to_env $PWD/.env mischief
43   $ cd .
44   Attempting to load unauthorized env file!
45   -* /tmp/cramtests-*/autoenv.t/.env (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   $ unset _autoenv_stack_entered
60   $ rm $AUTOENV_ENV_FILENAME
61   $ _autoenv_ask_for_yes() { echo "no"; return 1 }
62   $ cd .
63   Attempting to load unauthorized env file!
64   -* /tmp/cramtests-*/autoenv.t/.env (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   $ cd .
78   Attempting to load unauthorized env file!
79   -* /tmp/cramtests-*/autoenv.t/.env (glob)
80   
81   **********************************************
82   
83   echo ENTERED
84   
85   **********************************************
86   
87   Would you like to authorize it? (type 'yes') no