-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fake manifest tests: use new test repo * add upgrade test and initial sort test * use portable md5, adjust tests * more test changes * fix manifest ugprade tests * more test fixes
- Loading branch information
Showing
26 changed files
with
542 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,12 +29,12 @@ build: | |
run_tests: | ||
rm -rf tests/.get/packages tests/.get/tmp | ||
gcc -c $(MINIZIP)/*.c | ||
g++ -g tests/*.cpp src/*.cpp -std=gnu++20 -lm -lssl -lcrypto -L/usr/lib -L/usr/local/Cellar//[email protected]/1.1.0g/lib/ -I/usr/local/Cellar//[email protected]/1.1.0g/include -I $(RAPIDJSON) $(MINIZIP_O) -I $(MINIZIP) -lz -lcurl -o get_tests | ||
g++ -g tests/*.cpp src/*.cpp -std=gnu++20 -lm -L/usr/lib -I $(RAPIDJSON) $(MINIZIP_O) -I $(MINIZIP) -lz -lcurl -o get_tests | ||
cd tests/server && python3 -m http.server & | ||
export SERVERD=$! | ||
sleep 2 | ||
./get_tests | ||
|
||
clean: | ||
rm *.o get get_tests | ||
endif | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "tests.hpp" | ||
|
||
class FakeManifestUpgradeTest : public Test { | ||
public: | ||
FakeManifestUpgradeTest() { | ||
// depends on the previous test having succeeded | ||
purpose = "Packages without manifests can be upgraded"; | ||
} | ||
bool execute() | ||
{ | ||
// enable the 5th repo (server e) | ||
get->toggleRepo(*get->getRepos()[5]); | ||
|
||
// there should be 1 available UPDATE package, and 0 installed packages | ||
if (count(get, UPDATE) != 1 || count(get, INSTALLED) != 0) { | ||
error << "There should be 1 available UPDATE package, but there are " << count(get, UPDATE) << endl; | ||
error << "There should be 0 installed package, but there are " << count(get, INSTALLED) << endl; | ||
return false; | ||
} | ||
|
||
install(get, "missingmanifest"); | ||
|
||
if (!exists("sdroot/image.png")) { | ||
error << "The downloaded file in package 'missingmanifest' on server 'e' did not successfully extract" << endl; | ||
return false; | ||
} | ||
|
||
// there should be 1 INSTALLED package, and 0 upgrade packages | ||
if (count(get, UPDATE) != 0 || count(get, INSTALLED) != 1) { | ||
error << "There should be 0 available UPDATE package, but there are " << count(get, UPDATE) << endl; | ||
error << "There should be 1 installed package, but there are " << count(get, INSTALLED) << endl; | ||
return false; | ||
} | ||
|
||
std::string sum = calculateMD5("sdroot/image.png"); | ||
const char * rightSum = "26a7965e5aa6acced42de92eeee76d7a"; | ||
if (rightSum != sum) { | ||
error << "The downloaded file in package 'missingmanifest' on server 'e' has incorrect md5 sum, expected: " << rightSum << ", received: " << sum.c_str() << endl; | ||
return false; | ||
} | ||
|
||
// make sure the missingmanifest has "installed" state | ||
auto missingmanifest = get->lookup("missingmanifest"); | ||
if (!missingmanifest || missingmanifest->getStatus() != INSTALLED) { | ||
error << "The package 'missingmanifest' on server 'e' was not installed" << endl; | ||
return false; | ||
} | ||
|
||
// install one more time, and make sure we're still all good | ||
install(get, "missingmanifest"); | ||
|
||
sum = calculateMD5("sdroot/image.png"); | ||
if (rightSum != sum) { | ||
error << "The redownloaded file in package 'missingmanifest' on server 'e' has incorrect md5 sum, expected: " << rightSum << ", received: " << sum.c_str() << endl; | ||
return false; | ||
} | ||
|
||
// there should still be 1 INSTALLED package, and 0 upgrade packages | ||
if (count(get, UPDATE) != 0 || count(get, INSTALLED) != 1) { | ||
error << "There should be 0 available UPDATE package, but there are " << count(get, UPDATE) << endl; | ||
error << "There should be 1 installed package, but there are " << count(get, INSTALLED) << endl; | ||
return false; | ||
} | ||
|
||
// TODO: test zip extractions with an extra folder or no folder directory | ||
|
||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "tests.hpp" | ||
#include "../src/Utils.hpp" | ||
|
||
class PackagesSortedTest : public Test { | ||
public: | ||
PackagesSortedTest() { | ||
// TODO: support other sort modes directly in libget (currently in hb-appstore) | ||
// also TODO: the code doesn't do sorting at all! so implement that so this test passes | ||
purpose = "Packages return in alphabetically sorted order"; | ||
} | ||
bool execute() | ||
{ | ||
// enable all test repos | ||
for (int i = 0; i < get->getRepos().size(); i++) { | ||
get->getRepos()[i]->setEnabled(true); | ||
} | ||
get->update(); | ||
|
||
// get all packages from the server | ||
auto packages = get->list(); | ||
|
||
// create a sorted copy of the packages | ||
auto sorted = packages; | ||
std::sort(sorted.begin(), sorted.end(), [](const Package a, const Package b) { | ||
return toLower(a.getPackageName()) < toLower(b.getPackageName()); | ||
}); | ||
|
||
// compare the two lists | ||
for (int i = 0; i < packages.size(); i++) { | ||
if (packages[i].getPackageName() != sorted[i].getPackageName()) { | ||
error << "Package " << i << " is not sorted correctly" << endl; | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.