Gogs.GitMock (gogs v1.1.0)

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

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.

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

Link to this section Functions

@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://gogs-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

push(repository, args)

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

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

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