(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func 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) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…