MCPcopy
hub / github.com/go-git/go-git / TestVerifyExtensions

Function TestVerifyExtensions

repository_extensions_test.go:14–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestVerifyExtensions(t *testing.T) {
15 t.Parallel()
16
17 tests := []struct {
18 name string
19 setup func(*testing.T, *config.Config)
20 wantErr string
21 }{
22 {
23 name: "repositoryformatversion=0: invalid extension",
24 setup: func(t *testing.T, cfg *config.Config) {
25 cfg.Core.RepositoryFormatVersion = formatcfg.Version_0
26 cfg.Raw.Section("extensions").SetOption("unknown", "foo")
27 cfg.Raw.Section("extensions").SetOption("objectformat", "sha1")
28 },
29 wantErr: "repositoryformatversion does not support extension: unknown, objectformat",
30 },
31 {
32 name: "repositoryformatversion=0: allows supported noop",
33 setup: func(t *testing.T, cfg *config.Config) {
34 cfg.Core.RepositoryFormatVersion = formatcfg.Version_0
35 cfg.Raw.Section("extensions").SetOption("noop", "bar")
36 },
37 },
38 {
39 name: "repositoryformatversion='': allows supported noop",
40 setup: func(t *testing.T, cfg *config.Config) {
41 cfg.Raw.Section("extensions").SetOption("noop", "bar")
42 },
43 },
44 {
45 name: "repositoryformatversion=1: rejects unknown extensions",
46 setup: func(t *testing.T, cfg *config.Config) {
47 cfg.Core.RepositoryFormatVersion = formatcfg.Version_1
48 cfg.Raw.Section("extensions").SetOption("unknownext", "true")
49 },
50 wantErr: "unknown extension: unknownext",
51 },
52 {
53 name: "repositoryformatversion=1: allows known extension",
54 setup: func(t *testing.T, cfg *config.Config) {
55 cfg.Core.RepositoryFormatVersion = formatcfg.Version_1
56 cfg.Raw.Section("extensions").SetOption("NOOP", "foo")
57 cfg.Raw.Section("extensions").SetOption("noop-v1", "bar")
58 },
59 },
60 {
61 name: "repositoryformatversion=1: rejects objectformat=sha1", // not supported in go-git/v5
62 setup: func(t *testing.T, cfg *config.Config) {
63 cfg.Core.RepositoryFormatVersion = formatcfg.Version_1
64 cfg.Raw.Section("extensions").SetOption("objectformat", "sha1")
65 },
66 wantErr: "unknown extension: objectformat",
67 },
68 }
69
70 for _, tt := range tests {
71 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 9

NewStorageFunction · 0.92
InitFunction · 0.85
OpenFunction · 0.85
SectionMethod · 0.80
ConfigMethod · 0.65
SetConfigMethod · 0.65
ContainsMethod · 0.65
SetOptionMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…