Simplify test with setUp

This commit is contained in:
2021-12-21 02:35:10 -08:00
parent 9b11316463
commit d2322c0e5e
2 changed files with 42 additions and 106 deletions

View File

@@ -1,46 +1,39 @@
#!/usr/bin/env bash
setUp() {
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-n something \
-v 1337 \
-l http://something/VERSION/linux \
-d http://something/VERSION/darwin \
-- \
"$@"
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
}
testWrapperDownloadsFromLinuxUrlOnLinux() {
mock curl
mock uname Linux
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-l http://something/linux
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertCalledWithArguments curl http://something/linux
assertCalledWithArguments curl linux
}
testWrapperHasCurlFollowLocationHeader() {
mock curl
mock uname Linux
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-l http://something/linux
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertCalledWithArguments curl --location
@@ -51,43 +44,14 @@ testWrapperDownloadsFromDarwinUrlOnDarwin() {
mock curl
mock uname Darwin
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-d http://something/darwin
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertCalledWithArguments curl http://something/darwin
assertCalledWithArguments curl darwin
}
testWrapperSubstitutesVERSIONInUrl() {
mock curl
mock uname Darwin
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-v 1337 \
-d http://something/VERSION/darwin
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertCalledWithArguments curl http://something/1337/darwin
}
@@ -99,21 +63,6 @@ testWrapperRunsDownloadedBinary() {
'
mock uname Darwin
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-d http://something/darwin
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertContains "$STDOUT" "Hello friend"
}
@@ -124,22 +73,6 @@ testWrapperPersistsBinaryInLocationBasedOnNameAndVersion() {
'
mock uname Darwin
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-n something \
-v 1337 \
-d http://something/darwin
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
try ./go hello
assertContains "$(<.generated/wrapper/something/1337/bin)" potato
}
@@ -148,22 +81,6 @@ testWrapperDoesNotRedownloadBinaryIfPresent() {
mock curl 'whatever'
mock uname Darwin
echo '
#!/usr/bin/env bash
somethingw() {
_wrapper \
-n something \
-v 1337 \
-d http://something/darwin
}
⚡hello() { somethingw ; }
' > go
echo "source $REPO_ROOT/⚡" >> go
chmod +x go
mkdir -p .generated/wrapper/something/1337/
touch .generated/wrapper/something/1337/bin
try ./go hello