]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/_autoenv_utils.t
ee5b306b43f57f3ef3e5ea57356b04a3843d7c04
[zsh-autoenv.git] / tests / _autoenv_utils.t
1 Tests for internal util methods.
2
3   $ source $TESTDIR/setup.zsh || return 1
4
5 Non-existing entries are allowed and handled without error.
6
7   $ mkdir -p sub/sub2
8   $ touch file sub/file sub/sub2/file
9
10 Should not get the file from the current dir.
11
12   $ _autoenv_get_file_upwards . file
13
14   $ cd sub/sub2
15   $ _autoenv_get_file_upwards . file
16   */_autoenv_utils.t/sub/file (glob)
17
18
19 Tests for _autoenv_authorize. {{{
20
21 Auth file is empty.
22
23   $ cd ../..
24   $ cat $AUTOENV_AUTH_FILE
25
26 Failed authorization should keep the auth file empty.
27
28   $ _autoenv_authorize does-not-exist
29   Missing file argument for _autoenv_hash_pair!
30   [1]
31   $ cat $AUTOENV_AUTH_FILE
32
33 Now adding some auth pair.
34
35   $ echo first > first
36   $ _autoenv_authorize first
37   $ cat $AUTOENV_AUTH_FILE
38   :/tmp/cramtests-*/_autoenv_utils.t/first:271ac93c44ac198d92e706c6d6f1d84aefcfa337:1 (glob)
39
40 And a second one.
41
42   $ echo second > second
43   $ _autoenv_authorize second
44   $ cat $AUTOENV_AUTH_FILE
45   :/tmp/cramtests-*/_autoenv_utils.t/first:271ac93c44ac198d92e706c6d6f1d84aefcfa337:1 (glob)
46   :/tmp/cramtests-*/_autoenv_utils.t/second:7bee8f3b184e1e141ff76efe369c3b8bfc50e64c:1 (glob)
47
48 And a third.
49
50   $ echo third > third
51   $ _autoenv_authorize third
52   $ cat $AUTOENV_AUTH_FILE
53   :/tmp/cramtests-*/_autoenv_utils.t/first:271ac93c44ac198d92e706c6d6f1d84aefcfa337:1 (glob)
54   :/tmp/cramtests-*/_autoenv_utils.t/second:7bee8f3b184e1e141ff76efe369c3b8bfc50e64c:1 (glob)
55   :/tmp/cramtests-*/_autoenv_utils.t/third:ad180453bf8a374a15df3e90a78c180230146a7c:1 (glob)
56
57 Re-add the second one, with the same hash.
58
59   $ _autoenv_authorize second
60   $ cat $AUTOENV_AUTH_FILE
61   :/tmp/cramtests-*/_autoenv_utils.t/first:271ac93c44ac198d92e706c6d6f1d84aefcfa337:1 (glob)
62   :/tmp/cramtests-*/_autoenv_utils.t/third:ad180453bf8a374a15df3e90a78c180230146a7c:1 (glob)
63   :/tmp/cramtests-*/_autoenv_utils.t/second:7bee8f3b184e1e141ff76efe369c3b8bfc50e64c:1 (glob)
64
65 Re-add the first one, with a new hash.
66
67   $ echo one more line >> first
68   $ _autoenv_authorize first
69   $ cat $AUTOENV_AUTH_FILE
70   :/tmp/cramtests-*/_autoenv_utils.t/third:ad180453bf8a374a15df3e90a78c180230146a7c:1 (glob)
71   :/tmp/cramtests-*/_autoenv_utils.t/second:7bee8f3b184e1e141ff76efe369c3b8bfc50e64c:1 (glob)
72   :/tmp/cramtests-*/_autoenv_utils.t/first:65eb010197b73ddc109b7210080f97a87f53451e:1 (glob)
73 }}}
74
75
76 Explicit calls to _autoenv_get_file_mtime to test alternative implementation
77 of _autoenv_get_file_mtime (via ZDOTDIR.invalid-module_path/).
78
79   $ _autoenv_get_file_mtime non-existing
80   0
81   $ touch -t 201401010101 file
82   $ _autoenv_get_file_mtime file
83   1388538060
84   $ mkdir dir
85   $ touch -t 201401010102 dir
86   $ _autoenv_get_file_mtime dir
87   1388538120