Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple registries and repositories #248

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Add test for installing a dependency from gitlab and loading se…
…crets from a JSON file.
nouwaarom committed Dec 28, 2021
commit d80c2f4f52f8829fa233454d7acb5195215ef2a7
5 changes: 1 addition & 4 deletions src/repository/repository.c
Original file line number Diff line number Diff line change
@@ -118,10 +118,7 @@ repository_file_handle_t repository_download_package_file(const char *package_ur

void repository_file_finish_download(repository_file_handle_t file) {
void *rc;
int success = pthread_join(file->thread, &rc);
if (success != 0) {
printf("Failed to join thread.\n");
}
pthread_join(file->thread, &rc);
free(rc);
}

30 changes: 30 additions & 0 deletions test/install-from-gitlab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

throw() {
echo >&2 "$1"
exit 1
}

rm -rf tmp
mkdir -p tmp
cd tmp || exit

cat > clib.json << EOF
{
"registries": [
"https://gitlab.com/api/v4/projects/25447829/repository/files/README.md/raw?ref=master"
],
"dependencies": {
"nouwaarom/clib-dependency": "0.0.1"
}
}
EOF

clib install -c -o tmp > /dev/null ||
throw "expecting exit code of 0";

{ [ -d ./tmp/clib-dependency ] && [ -f ./tmp/clib-dependency/package.json ]; } ||
throw "failed to install clib-dependency"

cd - > /dev/null || exit
rm -rf ./tmp
4 changes: 4 additions & 0 deletions test/package/clib_secrets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"gitlab.com": "GitlabSecret",
"github.com": "GithubSecret"
}
22 changes: 22 additions & 0 deletions test/package/package-secrets-load.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "describe/describe.h"
#include <stdio.h>
#include "clib-secrets.h"

int main() {
describe("clib_secrets") {
it("should load secrets from a valid json.") {
clib_secrets_t secrets = clib_secrets_load_from_file("clib_secrets.json");
assert(secrets != NULL);
}

it("should provide secrets for a domain.") {
clib_secrets_t secrets = clib_secrets_load_from_file("clib_secrets.json");
char *github_secret = clib_secret_find_for_hostname(secrets, "github.com");
assert(strcmp(github_secret, "GithubSecret") == 0);
char *gitlab_secret = clib_secret_find_for_hostname(secrets, "gitlab.com");
assert(strcmp(gitlab_secret, "GitlabSecret") == 0);
}

return assert_failures();
}
}