MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / TestLoad

Function TestLoad

internal/config/config_test.go:12–111  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestLoad(t *testing.T) {
13 tests := []struct {
14 name string
15 content string
16 want *config.Config
17 wantErr bool
18 }{
19 {
20 name: "valid config",
21 content: `
22blocklist:
23 packages:
24 - "package-*"
25 mirrors:
26 - "mirror.com"
27`,
28 want: &config.Config{
29 Blocklist: struct {
30 Packages []string `mapstructure:"packages"`
31 Mirrors []string `mapstructure:"mirrors"`
32 }{
33 Packages: []string{"package-*"},
34 Mirrors: []string{"mirror.com"},
35 },
36 },
37 wantErr: false,
38 },
39 {
40 name: "empty config",
41 content: "",
42 want: &config.Config{},
43 wantErr: false,
44 },
45 {
46 name: "malformed config",
47 content: `
48blocklist:
49 packages: ["one"
50`,
51 want: nil,
52 wantErr: true,
53 },
54 {
55 name: "config with unknown field",
56 content: `
57blocklist:
58 packages:
59 - "package-*"
60 mirrors:
61 - "mirror.com"
62unknown_field: "value"
63`,
64 want: nil,
65 wantErr: true,
66 },
67 }
68
69 for _, tt := range tests {

Callers

nothing calls this directly

Calls 1

LoadFunction · 0.92

Tested by

no test coverage detected