forked from ramsey/composer-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache_key_01.exp
executable file
·51 lines (39 loc) · 1.15 KB
/
cache_key_01.exp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env -S expect -f
# For testing environment variables written to GITHUB_ENV
set gitHubEnvFile cache_key_01.txt
set ::env(GITHUB_ENV) $gitHubEnvFile
# For testing outputs variables written to GITHUB_OUTPUT
set gitHubOutputFile cache_key_output_01.txt
set ::env(GITHUB_OUTPUT) $gitHubOutputFile
set timeout 3
spawn ../../bin/cache_key.sh
match_max 100000
expect -exact "::debug::Cache primary key is 'php-composer-locked'"
expect -exact "::debug::Cache restore keys are 'php-composer-locked-'"
expect eof
# Confirm environment variables.
set fp [open $gitHubEnvFile r]
set fileData [read $fp]
close $fp
set expectedValue "CACHE_RESTORE_KEY<<EOF
php-composer-locked-
EOF
"
if { $expectedValue != $fileData } {
puts "\nExpected environment variable does not match. Received:\n"
puts $fileData
exit 1
}
# Confirm environment variables.
set fp [open $gitHubOutputFile r]
set fileData [read $fp]
close $fp
set expectedValue "key=php-composer-locked\n"
if { $expectedValue != $fileData } {
puts "\nExpected output variable does not match. Received:\n"
puts $fileData
exit 1
}
# Clean up
file delete $gitHubEnvFile
file delete $gitHubOutputFile