1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package ermitegit_test
4
5import (
6 "testing"
7
8 "bnema.dev/ermite/internal/adapters/ermitegit"
9 "bnema.dev/ermite/internal/readertest"
10)
11
12// TestCompareWithCLI asks the CLI reader and the adapter, with every method on
13// ermite-git, the same questions about each fixture and requires the same
14// answers, errors included.
15func TestCompareWithCLI(t *testing.T) {
16 for _, c := range readertest.Cases() {
17 t.Run(c.Name, func(t *testing.T) {
18 a, g, data := newAdapter(t, ermitegit.AllRoutes(ermitegit.ErmiteGit), nil)
19 f := c.Build(t, data)
20 readertest.Compare(t, g, a, f.Name, f.Bare, readertest.SmallBudget)
21 })
22 }
23}
24
25// TestCompareDefaultRoutes is the comparison through the routes of production.
26func TestCompareDefaultRoutes(t *testing.T) {
27 for _, c := range readertest.Cases() {
28 t.Run(c.Name, func(t *testing.T) {
29 a, g, data := newAdapter(t, ermitegit.DefaultRoutes(), nil)
30 f := c.Build(t, data)
31 readertest.Compare(t, g, a, f.Name, f.Bare, readertest.SmallBudget)
32 })
33 }
34}
35
36// TestCompareWithCLIOnBenchRepo is the same comparison on a real repository
37// (ERMITE_GIT_BENCH_REPO, for instance lazygit): clone, maintenance as ermite
38// runs it, then the questions on refs, trees with last commits, blobs and
39// pages of history.
40func TestCompareWithCLIOnBenchRepo(t *testing.T) {
41 a, g, data := newAdapter(t, ermitegit.AllRoutes(ermitegit.ErmiteGit), nil)
42 repo := cloneBench(t, g, data)
43 readertest.Compare(t, g, a, repo.name, repo.dir, readertest.LargeBudget)
44}