import io
import tarfile


def _tarify_contents(file_name: str, contents: str) -> bytes:
    """
    Returns a tarball as a bytestream containing a single file with the given name and contents.

    Args:
        file_name: A string corresponding to the name of the file in the tarball.
        contents: A string corresponding to the Contents of the file in the tarball.

    Returns:
        (bytes): Bytes corresponding to the tarball.
    """
    output_bytes = io.BytesIO()
    tar = tarfile.TarFile(fileobj=output_bytes, mode="w")
    added_file = tarfile.TarInfo(name=file_name)

    encoded_string = str.encode(contents)
    added_file.size = len(encoded_string)
    tar.addfile(added_file, io.BytesIO(encoded_string))
    tar.close()

    output_bytes.seek(0)
    return output_bytes.getvalue()