# Path: gg/main.py
# class Config:
#     def __init__(self):
#         self.verbose = False  # default
#         self.configfile = DEFAULT_CONFIGFILE
#         try:
#             self.repo = get_repo()
#         except git.InvalidGitRepositoryError as exception:
#             error_out(f"{exception.args[0]} is not a git repository")
# 
# Path: gg/builtins/config.py
# @cli.command()
# @click.option(
#     "-f",
#     "--fork-name",
#     default="",
#     help="Name of the remote which is the fork where you push your branches.",
# )
# @click.option(
#     "-o",
#     "--origin-name",
#     default="",
#     help="Name of the remote which is the origin remote.",
# )
# @click.option(
#     "-b",
#     "--default-branch",
#     default="",
#     help="Name of the default branch.",
# )
# @pass_config
# def config(config, fork_name="", origin_name="", default_branch=""):
#     """Setting various configuration options"""
#     state = read(config.configfile)
#     if fork_name:
#         update(config.configfile, {"FORK_NAME": fork_name})
#         success_out(f"fork-name set to: {fork_name}")
#     else:
#         info_out(f"fork-name: {state['FORK_NAME']}")
# 
#     if origin_name:
#         update(config.configfile, {"ORIGIN_NAME": origin_name})
#         success_out(f"origin-name set to: {origin_name}")
#     else:
#         info_out(f"origin-name: {state.get('ORIGIN_NAME', '*not set*')}")
# 
#     if default_branch:
#         update(config.configfile, {"DEFAULT_BRANCH": default_branch})
#         success_out(f"default-branch set to: {default_branch}")
#     else:
#         info_out(f"default-branch: {state.get('DEFAULT_BRANCH', '*not set*')}")


import json
from click.testing import CliRunner
from gg.main import Config
from gg.builtins import config




def test_config(temp_configfile, mocker):
    # rget = mocker.patch('requests.get')
    getpass = mocker.patch("getpass.getpass")
    getpass.return_value = "somelongapitokenhere"

    runner = CliRunner()
    config_ = Config()
    config_.configfile = temp_configfile

# Path: gg/main.py
# class Config:
#     def __init__(self):
#         self.verbose = False  # default
#         self.configfile = DEFAULT_CONFIGFILE
#         try:
#             self.repo = get_repo()
#         except git.InvalidGitRepositoryError as exception:
#             error_out(f"{exception.args[0]} is not a git repository")
# 
# Path: gg/builtins/config.py
# @cli.command()
# @click.option(
#     "-f",
#     "--fork-name",
#     default="",
#     help="Name of the remote which is the fork where you push your branches.",
# )
# @click.option(
#     "-o",
#     "--origin-name",
#     default="",
#     help="Name of the remote which is the origin remote.",
# )
# @click.option(
#     "-b",
#     "--default-branch",
#     default="",
#     help="Name of the default branch.",
# )
# @pass_config
# def config(config, fork_name="", origin_name="", default_branch=""):
#     """Setting various configuration options"""
#     state = read(config.configfile)
#     if fork_name:
#         update(config.configfile, {"FORK_NAME": fork_name})
#         success_out(f"fork-name set to: {fork_name}")
#     else:
#         info_out(f"fork-name: {state['FORK_NAME']}")
# 
#     if origin_name:
#         update(config.configfile, {"ORIGIN_NAME": origin_name})
#         success_out(f"origin-name set to: {origin_name}")
#     else:
#         info_out(f"origin-name: {state.get('ORIGIN_NAME', '*not set*')}")
# 
#     if default_branch:
#         update(config.configfile, {"DEFAULT_BRANCH": default_branch})
#         success_out(f"default-branch set to: {default_branch}")
#     else:
#         info_out(f"default-branch: {state.get('DEFAULT_BRANCH', '*not set*')}")


# Path: tests/test_config.py
import json
from click.testing import CliRunner
from gg.main import Config
from gg.builtins import config





def test_config(temp_configfile, mocker):
    # rget = mocker.patch('requests.get')
    getpass = mocker.patch("getpass.getpass")
    getpass.return_value = "somelongapitokenhere"

    runner = CliRunner()
    config_ = Config()
    config_.configfile = temp_configfile

    result = runner.invoke(config.config, ["-f", "myown"], obj=config_)