TruCol / Self-host-GitLab-CI-for-GitHub

Installs your own GitLab CI and runs it on all your GitHub repos, in a single command.
GNU Affero General Public License v3.0
4 stars 3 forks source link

Restore test_run_ci_on_github_repo.bats #72

Open a-t-0 opened 2 years ago

a-t-0 commented 2 years ago

Restore the tests in test_run_ci_on_github_repo.bats in the updated code, which has been restructured and improved towards Google Bash Style guide compliance. This requires some effort. The first test of this file passes. Currently the second test is being restored:

@test "Test copying github branches with yaml to GitLab repo." {
    local github_username="a-t-0"
    local github_repo_name="sponsor_example"

    # Delete the repository locally if it exists.
    remove_dir "$MIRROR_LOCATION/GitHub/$github_repo_name"
    manual_assert_dir_not_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"

    # TODO: change this method to download with https?
    # Download the GitHub repo on which to run the GitLab CI:
    download_github_repo_on_which_to_run_ci "$github_username" "$github_repo_name"
    manual_assert_dir_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"

    repo_was_cloned=$(verify_github_repository_is_cloned "$github_repo_name" "$MIRROR_LOCATION/GitHub/$github_repo_name")
    assert_equal "$repo_was_cloned" "FOUND"

    copy_github_branches_with_yaml_to_gitlab_repo "$github_username" "$github_repo_name"
    # TODO: write some assert to verify yamls are copied to GitLab repo.

    # Delete the repository locally if it exists.
    remove_dir "$MIRROR_LOCATION/GitHub/$github_repo_name"
    manual_assert_dir_not_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"
}

An issue in this test is that it requires using the GitLab personal access token, which has not yet been generated by the .install_gitlab.sh -s -r command. This test requires that token because it runs:

copy_github_branches_with_yaml_to_gitlab_repo

From

run_ci_on_github_repo.sh

which calls:

get_project_list(){

which asks the repositories from the GitLab API using the GitLab personal access token. Additionally, the function to manually create this token:

create_gitlab_personal_access_token()

in file: create_personal_access_token.sh throws an error.

Solution

a-t-0 commented 2 years ago

Remove get_last_line_of_set_of_lines as it evaluates the incoming lines.

a-t-0 commented 2 years ago

See #6