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