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

Function TestShowInformationToBeSent

cmd/submit_test.go:14–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestShowInformationToBeSent(t *testing.T) {
15 s := system.NewSystem()
16 osArchitecture, err := s.GetArchitecture()
17 if err != nil {
18 t.Fatal(err)
19 }
20 cpuArchitecture, err := s.GetCpuArchitecture()
21 if err != nil {
22 t.Fatal(err)
23 }
24 osId, err := s.GetOSId()
25 if err != nil {
26 t.Fatal(err)
27 }
28
29 output, err := pkgstats(t, []string{"submit", "--dump-json"}, WithPkgBlocklist([]string{"secret-*"}), WithMirrorBlocklist([]string{"secret.com"}))
30 if err != nil {
31 t.Fatalf("Failed to run command: %v", err)
32 }
33 var request submit.Request
34 if err := json.Unmarshal([]byte(output), &request); err != nil {
35 t.Fatalf("Failed to unmarshal JSON: %v", err)
36 }
37 if request.Version != submit.Version {
38 t.Errorf("Expected version %s, got %v", submit.Version, request.Version)
39 }
40 if request.System.Architecture != cpuArchitecture {
41 t.Errorf("Expected system architecture '%s', got %v", cpuArchitecture, request.System.Architecture)
42 }
43 if request.OS.Architecture != osArchitecture {
44 t.Errorf("Expected OS architecture '%s', got %v", osArchitecture, request.OS.Architecture)
45 }
46 if request.OS.Id != osId {
47 t.Errorf("Expected OS id '%s', got %v", osId, request.OS.Id)
48 }
49 if !strings.HasPrefix(request.Pacman.Mirror, "https://") {
50 t.Errorf("Expected pacman mirror to start with 'https://', got %v", request.Pacman.Mirror)
51 }
52 if !slices.Contains(request.Pacman.Packages, "pacman-mirrorlist") {
53 t.Errorf("Expected pacman packages to contain 'pacman-mirrorlist'")
54 }
55 if slices.Contains(request.Pacman.Packages, "secret-package") {
56 t.Errorf("Expected pacman packages to not contain 'secret-package'")
57 }
58}
59
60func TestMirrorFiltering(t *testing.T) {
61 if os.Getenv("INTEGRATION_TEST") == "1" {

Callers

nothing calls this directly

Calls 7

GetArchitectureMethod · 0.95
GetCpuArchitectureMethod · 0.95
GetOSIdMethod · 0.95
NewSystemFunction · 0.92
pkgstatsFunction · 0.85
WithPkgBlocklistFunction · 0.85
WithMirrorBlocklistFunction · 0.85

Tested by

no test coverage detected