Skip to content

Commit

Permalink
restore Mock.checkout function
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed May 5, 2022
1 parent 0df5c0d commit ec08eb4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/gogs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,13 @@ defmodule Gogs do
"""
@spec local_branch_create(String.t(), String.t()) :: {:ok, map} | {:error, any}
def local_branch_create(repo_name, _branch_name \\ "draft") do
# inject_git().checkout(local_git_repo(repo_name), ~w(-b draft))
Git.checkout(local_git_repo(repo_name), ~w(-b draft))
inject_git().checkout(local_git_repo(repo_name), ~w(-b draft))
end

@spec local_file_write_text(String.t(), String.t(), String.t()) :: :ok | {:error, any}
def local_file_write_text(repo_name, file_name, text) do
file_path = Path.join([local_repo_path(repo_name), file_name])
# IO.inspect("attempting to write to #{file_path}")
# Logger.info("attempting to write to #{file_path}")
File.touch!(file_path)
File.write(file_path, text)
end
Expand Down
6 changes: 5 additions & 1 deletion test/gogs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ defmodule GogsTest do
delete_local_directory(repo)
end

test "Gogs.clone error branch" do
test "Gogs.clone error (simulate unhappy path)" do
repo = "error"
org = "nelsonic"
git_repo_url = GogsHelpers.remote_url_ssh(org, repo)
Expand All @@ -73,12 +73,16 @@ defmodule GogsTest do

test "local_branch_create/1 creates a new branch on the localhost" do
repo_name = create_test_git_repo("myorg")
# delete before if exists:
Git.branch(GogsHelpers.local_git_repo(repo_name), ~w(-D draft))

{:ok, res} = Gogs.local_branch_create(repo_name, "draft")
assert res == "Switched to a new branch 'draft'\n"

# Cleanup!
Gogs.remote_repo_delete("myorg", repo_name)
delete_local_directory(repo_name)
Git.branch(GogsHelpers.local_git_repo(repo_name), ~w(-D draft))
end


Expand Down

0 comments on commit ec08eb4

Please sign in to comment.