]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/autoenv.t
Add tests
[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 The last "blah" is because it executed the command
32
33 Now lets see that it actually checks the shasum value
34
35   $ cd .
36   blah
37   $ rm $ENV_AUTHORIZATION_FILE
38   $ echo "$PWD/.env:$(echo mischief | shasum)" > $ENV_AUTHORIZATION_FILE
39   $ cd .
40   Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
41
42   **********************************************
43
44   echo blah
45
46   **********************************************
47
48   Would you like to authorize it? (y/n)
49   blah
50
51 Now, will it take no for an answer?
52
53   $ rm $ENV_AUTHORIZATION_FILE
54   $ _dotenv_read_answer() { answer='n' }
55   $ cd .
56   Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
57
58   **********************************************
59
60   echo blah
61
62   **********************************************
63
64   Would you like to authorize it? (y/n)
65
66 Lets also try one more time to ensure it didnt add it
67
68   $ cd .
69   Attempting to load unauthorized env: /tmp/cramtests-??????/autoenv.t/.env (glob)
70
71   **********************************************
72
73   echo blah
74
75   **********************************************
76
77   Would you like to authorize it? (y/n)