Gitea.GitMock (gitea v1.1.11)

Mock functions to simulate Git commands. Sadly, this is necessary until we figure out how to get write-access on GitHub CI. This module is exported for testing convenience/speed in downstream/dependent apps.

Link to this section Summary

Functions

add/2 (mock) simulate a commit and always returns {:ok, any}

clone/1 (mock) returns the path of the existing test-repo so that no remote cloning occurs. This is needed for CI and is used in downstream tests to speed up suite execution.

commit/2 (mock) simulate a commit and always returns {:ok, commit_info}

push/1 (mock) pushes the latest commits on the current branch to the Gitea remote repository.

Link to this section Functions

Link to this function

add(repo_path, args)

@spec add(Git.Repository.t(), [any()]) :: {:ok, any()}

add/2 (mock) simulate a commit and always returns {:ok, any}

@spec clone(String.t() | [String.t()]) ::
  {:ok, Git.Repository.t()} | {:error, Git.Error}

clone/1 (mock) returns the path of the existing test-repo so that no remote cloning occurs. This is needed for CI and is used in downstream tests to speed up suite execution.

## Examples iex> GitMock.clone("ssh://gitea-server.fly.dev:10022/myorg/public-repo.git") {:ok, %Git.Repository{path: "/path/to/public-repo"}}

iex> GitMock.clone("any-url-containing-the-word-error-to-trigger-failure") {:error, %Git.Error{message: "git clone error (mock)"}}

Link to this function

commit(repo, args)

@spec commit(Git.Repository.t(), [any()]) :: {:ok, any()}

commit/2 (mock) simulate a commit and always returns {:ok, commit_info}

Link to this function

push(repository, args)

@spec push(Git.Repository.t(), [any()]) :: {:ok, any()}

push/1 (mock) pushes the latest commits on the current branch to the Gitea remote repository.

## Examples iex> GitMock.push("my-repo") {:ok, "To ssh://gitea-server.fly.dev:10022/myorg/my-repo.git "}