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

Function createPacmanConf

cmd/testhelper_pacman_test.go:13–33  ·  view source on GitHub ↗
(t *testing.T, mirror string)

Source from the content-addressed store, hash-verified

11)
12
13func createPacmanConf(t *testing.T, mirror string) string {
14 t.Helper()
15
16 s := system.NewSystem()
17 osArchitecture, err := s.GetArchitecture()
18 if err != nil {
19 t.Fatal(err)
20 }
21 dbPath := createPacmanDBPath(t)
22
23 if mirror == "" {
24 mirror = "https://geo.mirror.pkgbuild.com/core/os/"
25 }
26
27 pacmanConfFile := filepath.Join(t.TempDir(), "pacman.conf")
28 if err := os.WriteFile(pacmanConfFile, fmt.Appendf(nil, "[options]\nDBPath=%s\n[core]\nServer=%s%s", dbPath, mirror, osArchitecture), 0o600); err != nil {
29 t.Fatalf("Failed to create pacman.conf: %v", err)
30 }
31
32 return pacmanConfFile
33}
34
35func createPacmanDBPath(t *testing.T) string {
36 t.Helper()

Callers 1

pkgstatsFunction · 0.70

Calls 3

GetArchitectureMethod · 0.95
NewSystemFunction · 0.92
createPacmanDBPathFunction · 0.85

Tested by

no test coverage detected