Skip to content

Convert `gitserver.DefaultClient` to an interface

Warren Gifford requested to merge backend-dry-run/cc/gitserver-interface into main

Created by: camdencheek

This creates a gitserver.Client interface, and converts gitserver.DefaultClient to be that type. The motivation here is that I really want to be able to swap out DefaultGitserver with a mocked version in search tests, but that's currently not possible. Ideally, we'd go as far as to pass in a gitserver.Client object to the search code, but we're not there yet.

To do this, I needed to get rid of places where the publically-exposed Addrs field is mutated and make it private. This meant making a new method NewTestClient that lets you pass in a hard-coded set of addrs.

Ideally, with a real interface type, we will be able to pass that type around through code that needs tested so we can just pass in a generated mock implementation instead.

@ryanslade Added you as a reviewer because IIRC, you had/have been working on some hexagonal architecture stuff for gitserver

Merge request reports

Loading