2021-12-21 10:00:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-12-21 10:35:10 +00:00
|
|
|
setUp() {
|
2021-12-21 10:00:48 +00:00
|
|
|
echo '
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
somethingw() {
|
|
|
|
_wrapper \
|
2021-12-21 10:35:10 +00:00
|
|
|
-n something \
|
|
|
|
-v 1337 \
|
|
|
|
-l http://something/VERSION/linux \
|
|
|
|
-d http://something/VERSION/darwin \
|
|
|
|
-- \
|
|
|
|
"$@"
|
2021-12-21 10:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
⚡hello() { somethingw ; }
|
|
|
|
' > go
|
|
|
|
|
|
|
|
echo "source $REPO_ROOT/⚡" >> go
|
|
|
|
chmod +x go
|
2021-12-21 10:35:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperDownloadsFromLinuxUrlOnLinux() {
|
|
|
|
mock curl
|
|
|
|
mock uname Linux
|
2021-12-21 10:00:48 +00:00
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
|
2021-12-21 10:35:10 +00:00
|
|
|
assertCalledWithArguments curl linux
|
2021-12-21 10:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperHasCurlFollowLocationHeader() {
|
|
|
|
mock curl
|
|
|
|
mock uname Linux
|
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
|
|
|
|
assertCalledWithArguments curl --location
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
testWrapperDownloadsFromDarwinUrlOnDarwin() {
|
|
|
|
mock curl
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
try ./go hello
|
2021-12-21 10:35:10 +00:00
|
|
|
assertCalledWithArguments curl darwin
|
2021-12-21 10:00:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperSubstitutesVERSIONInUrl() {
|
|
|
|
mock curl
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
assertCalledWithArguments curl http://something/1337/darwin
|
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperRunsDownloadedBinary() {
|
|
|
|
mock curl '#!/usr/bin/env bash
|
|
|
|
printf "Hello "
|
|
|
|
printf "friend"
|
|
|
|
'
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
assertContains "$STDOUT" "Hello friend"
|
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperPersistsBinaryInLocationBasedOnNameAndVersion() {
|
|
|
|
mock curl '#!/usr/bin/env true
|
|
|
|
potato
|
|
|
|
'
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
assertContains "$(<.generated/wrapper/something/1337/bin)" potato
|
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperDoesNotRedownloadBinaryIfPresent() {
|
|
|
|
mock curl 'whatever'
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
mkdir -p .generated/wrapper/something/1337/
|
|
|
|
touch .generated/wrapper/something/1337/bin
|
|
|
|
try ./go hello
|
|
|
|
assertNotCalled curl
|
|
|
|
assertNotContains "$(<.generated/wrapper/something/1337/bin)" potato
|
|
|
|
}
|
|
|
|
|
|
|
|
testWrapperPassesArgumentsToExecutedBinary() {
|
|
|
|
mock curl '#!/usr/bin/env bash
|
|
|
|
echo "$@"
|
|
|
|
'
|
|
|
|
mock uname Darwin
|
|
|
|
|
|
|
|
echo '
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
somethingw() {
|
|
|
|
_wrapper \
|
|
|
|
-n something \
|
|
|
|
-v 1337 \
|
|
|
|
-d http://something/darwin \
|
|
|
|
-- \
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
⚡hello() { somethingw Hello friend ; }
|
|
|
|
' > go
|
|
|
|
|
|
|
|
echo "source $REPO_ROOT/⚡" >> go
|
|
|
|
chmod +x go
|
|
|
|
|
|
|
|
try ./go hello
|
|
|
|
assertContains "$STDOUT" "Hello friend"
|
|
|
|
}
|
|
|
|
|
|
|
|
source $(dirname $0)/runner
|