(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestPrintUpdateList(t *testing.T) { |
| 32 | // The current method of capturing os.Stdout hinders parallelization. |
| 33 | // Setting of global settings.NoConfirm in printUpdateList also hinders parallelization. |
| 34 | // t.Parallel() |
| 35 | // Cannot run in parallel: mutates text.NowFunc and settings.NoConfirm, both package-level vars. |
| 36 | // Pin time so FormatAgeTag output is deterministic across test runs. |
| 37 | const testPkgLastModified int64 = 1646250901 |
| 38 | text.NowFunc = func() time.Time { return time.Unix(testPkgLastModified+365*24*3600, 0) } |
| 39 | t.Cleanup(func() { text.NowFunc = time.Now }) |
| 40 | pacmanBin := t.TempDir() + "/pacman" |
| 41 | f, err := os.OpenFile(pacmanBin, os.O_RDONLY|os.O_CREATE, 0o755) |
| 42 | require.NoError(t, err) |
| 43 | require.NoError(t, f.Close()) |
| 44 | |
| 45 | mockDBName := mock.NewDB("core") |
| 46 | mockDB := &mock.DBExecutor{ |
| 47 | AlpmArchitecturesFn: func() ([]string, error) { |
| 48 | return []string{"x86_64"}, nil |
| 49 | }, |
| 50 | RefreshHandleFn: func() error { |
| 51 | return nil |
| 52 | }, |
| 53 | ReposFn: func() []string { |
| 54 | return []string{"core"} |
| 55 | }, |
| 56 | InstalledRemotePackagesFn: func() map[string]alpm.Package { |
| 57 | return map[string]alpm.Package{ |
| 58 | "vosk-api": &mock.Package{ |
| 59 | PName: "vosk-api", |
| 60 | PVersion: "0.3.43-1", |
| 61 | PBase: "vosk-api", |
| 62 | PReason: alpm.PkgReasonExplicit, |
| 63 | }, |
| 64 | } |
| 65 | }, |
| 66 | InstalledRemotePackageNamesFn: func() []string { |
| 67 | return []string{"vosk-api"} |
| 68 | }, |
| 69 | SyncUpgradesFn: func( |
| 70 | bool, |
| 71 | ) (map[string]db.SyncUpgrade, error) { |
| 72 | return map[string]db.SyncUpgrade{ |
| 73 | "linux": { |
| 74 | Package: &mock.Package{ |
| 75 | PName: "linux", |
| 76 | PVersion: "5.10.0", |
| 77 | PDB: mockDBName, |
| 78 | }, |
| 79 | LocalVersion: "4.3.0", |
| 80 | Reason: alpm.PkgReasonExplicit, |
| 81 | }, |
| 82 | "go": { |
| 83 | Package: &mock.Package{ |
| 84 | PName: "go", |
| 85 | PVersion: "2:1.20.4-1", |
| 86 | PDB: mockDBName, |
| 87 | }, |
| 88 | LocalVersion: "2:1.20.3-1", |
nothing calls this directly
no test coverage detected