# Path: releasetool/commands/tag/ruby.py
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
# 
#     for name in RUBY_CLIENT_REPOS:
#         if name in upstream_repo:
#             return f"cloud-devrel/client-libraries/{name}/release"
#     for name in RUBY_CLOUD_REPOS:
#         if name in upstream_repo:
#             return f"cloud-devrel/ruby/{name}/release"
# 
#     return f"cloud-devrel/client-libraries/{package_name}/release"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     head_ref = pull["head"]["ref"]
#     click.secho(f"PR head ref is {head_ref}")
#     match = re.match(r"release-(.+)-v(\d+\.\d+\.\d+)", head_ref)
#     if match is None:
#         return None
# 
#     return match.group(1)


from releasetool.commands.tag.ruby import kokoro_job_name, package_name
# See the License for the specific language governing permissions and
# limitations under the License.



def test_kokoro_job_name():
    job_name = kokoro_job_name("upstream-owner/upstream-repo", "some-package-name")
    assert job_name == "cloud-devrel/client-libraries/some-package-name/release"


def test_kokoro_job_name_gapic():
    job_name = kokoro_job_name(
        "googleapis/google-cloud-ruby", "google-cloud-video-intelligence"
    )
    assert job_name == "cloud-devrel/client-libraries/google-cloud-ruby/release"


def test_kokoro_job_name_functions_framework():
    job_name = kokoro_job_name(
        "GoogleCloud/functions-framework-ruby", "functions_framework"
    )
    assert job_name == "cloud-devrel/ruby/functions-framework-ruby/release"


def test_kokoro_job_name_apiary():
    job_name = kokoro_job_name("googleapis/google-api-ruby-client", "youtube")
    assert job_name == "cloud-devrel/client-libraries/google-api-ruby-client/release"


def test_package_name():

# Path: releasetool/commands/tag/ruby.py
# def kokoro_job_name(upstream_repo: str, package_name: str) -> Union[str, None]:
#     """Return the Kokoro job name.
# 
#     Args:
#         upstream_repo (str): The GitHub repo in the form of `<owner>/<repo>`
#         package_name (str): The name of package to release
# 
#     Returns:
#         The name of the Kokoro job to trigger or None if there is no job to trigger
#     """
# 
#     for name in RUBY_CLIENT_REPOS:
#         if name in upstream_repo:
#             return f"cloud-devrel/client-libraries/{name}/release"
#     for name in RUBY_CLOUD_REPOS:
#         if name in upstream_repo:
#             return f"cloud-devrel/ruby/{name}/release"
# 
#     return f"cloud-devrel/client-libraries/{package_name}/release"
# 
# def package_name(pull: dict) -> Union[str, None]:
#     head_ref = pull["head"]["ref"]
#     click.secho(f"PR head ref is {head_ref}")
#     match = re.match(r"release-(.+)-v(\d+\.\d+\.\d+)", head_ref)
#     if match is None:
#         return None
# 
#     return match.group(1)


# Path: tests/commands/tag/test_tag_ruby.py
from releasetool.commands.tag.ruby import kokoro_job_name, package_name

# See the License for the specific language governing permissions and
# limitations under the License.



def test_kokoro_job_name():
    job_name = kokoro_job_name("upstream-owner/upstream-repo", "some-package-name")
    assert job_name == "cloud-devrel/client-libraries/some-package-name/release"


def test_kokoro_job_name_gapic():
    job_name = kokoro_job_name(
        "googleapis/google-cloud-ruby", "google-cloud-video-intelligence"
    )
    assert job_name == "cloud-devrel/client-libraries/google-cloud-ruby/release"


def test_kokoro_job_name_functions_framework():
    job_name = kokoro_job_name(
        "GoogleCloud/functions-framework-ruby", "functions_framework"
    )
    assert job_name == "cloud-devrel/ruby/functions-framework-ruby/release"


def test_kokoro_job_name_apiary():
    job_name = kokoro_job_name("googleapis/google-api-ruby-client", "youtube")
    assert job_name == "cloud-devrel/client-libraries/google-api-ruby-client/release"


def test_package_name():

    name = package_name({"head": {"ref": "release-storage-v1.2.3"}})