]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/autoenv.t
s/ENV_AUTHORIZATION_FILE/AUTOENV_ENV_FILENAME/
[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   $ echo "$PWD/.env:$(echo echo ENTERED | shasum)" > $AUTOENV_ENV_FILENAME
10   $ cd .
11   ENTERED
12
13 Now try to make it accept it
14
15   $ unset _dotenv_stack_entered
16   $ rm $AUTOENV_ENV_FILENAME
17   $ _dotenv_read_answer() { echo 'y' }
18   $ cd .
19   Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
20   
21   **********************************************
22   
23   echo ENTERED
24   
25   **********************************************
26   
27   Would you like to authorize it? [y/N] 
28   ENTERED
29
30
31
32
33
34 The last "ENTERED" is because it executed the command
35
36 Now lets see that it actually checks the shasum value
37
38   $ unset _dotenv_stack_entered
39   $ cd .
40   ENTERED
41
42   $ unset _dotenv_stack_entered
43   $ rm $AUTOENV_ENV_FILENAME
44   $ echo "$PWD/.env:$(echo mischief | shasum)" > $AUTOENV_ENV_FILENAME
45   $ cd .
46   Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
47   
48   **********************************************
49   
50   echo ENTERED
51   
52   **********************************************
53   
54   Would you like to authorize it? [y/N] 
55   ENTERED
56
57
58
59
60
61 Now, will it take no for an answer?
62
63   $ unset _dotenv_stack_entered
64   $ rm $AUTOENV_ENV_FILENAME
65   $ _dotenv_read_answer() { echo 'n' }
66   $ cd .
67   Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
68   
69   **********************************************
70   
71   echo ENTERED
72   
73   **********************************************
74   
75   Would you like to authorize it? [y/N] 
76
77
78
79
80
81 Lets also try one more time to ensure it didnt add it
82
83   $ cd .
84   Attempting to load unauthorized env file: /tmp/cramtests-??????/autoenv.t/.env (glob)
85   
86   **********************************************
87   
88   echo ENTERED
89   
90   **********************************************
91   
92   Would you like to authorize it? [y/N]