(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func 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 | |
| 60 | func TestMirrorFiltering(t *testing.T) { |
| 61 | if os.Getenv("INTEGRATION_TEST") == "1" { |
nothing calls this directly
no test coverage detected