]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/upgrade_hash.t
Simplify and lower LoC
[zsh-autoenv.git] / tests / upgrade_hash.t
1 Tests for upgrading hashes.
2
3   $ source $TESTDIR/setup.zsh || return 1
4
5   $ mkdir -p sub
6   $ mkdir -p ${AUTOENV_AUTH_FILE:h}
7
8 Create a single v1 hash entry.
9
10   $ echo 'echo ENTERED' > sub/$AUTOENV_FILE_ENTER
11   $ echo 'echo LEAVE' > sub/$AUTOENV_FILE_LEAVE
12
13   $ echo :$PWD/sub/$AUTOENV_FILE_ENTER:4c403f1870af2ab5472370a42b6b2b488cefe83c:1 >| $AUTOENV_AUTH_FILE
14   $ cd sub
15   ENTERED
16
17 Hashes should get upgraded automatically.
18 This also tests that there are no empty lines being added to the auth file when
19 de-authenticating the old hash.
20
21   $ cat $AUTOENV_AUTH_FILE
22   :/*/cramtests-*/upgrade_hash.t/sub/.autoenv.zsh:3679467995.13:2 (glob)
23
24 Re-create auth file with v1 hashes for both auth files.
25
26   $ echo :$PWD/$AUTOENV_FILE_LEAVE:882cf0333ea3c35537c9459c08d8987f25087ea9:1 >| $AUTOENV_AUTH_FILE
27   $ echo :$PWD/$AUTOENV_FILE_ENTER:4c403f1870af2ab5472370a42b6b2b488cefe83c:1 >>| $AUTOENV_AUTH_FILE
28
29 Only the leave file's hash should get updated.
30
31   $ cd ..
32   LEAVE
33   $ cat $AUTOENV_AUTH_FILE
34   :/*/cramtests-*/upgrade_hash.t/sub/.autoenv.zsh:4c403f1870af2ab5472370a42b6b2b488cefe83c:1 (glob)
35   :/*/cramtests-*/upgrade_hash.t/sub/.autoenv_leave.zsh:803077150.11:2 (glob)
36
37 The enter file's hash should get updated.
38
39   $ cd sub
40   ENTERED
41   $ cat $AUTOENV_AUTH_FILE
42   :/*/cramtests-*/upgrade_hash.t/sub/.autoenv_leave.zsh:803077150.11:2 (glob)
43   :/*/cramtests-*/upgrade_hash.t/sub/.autoenv.zsh:3679467995.13:2 (glob)