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