1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Pass "now" into utils.Loader

This makes it possible to write deterministic tests for views that use it.
This commit is contained in:
Stefan Haller
2023-10-14 15:31:13 +02:00
parent 58a83b0862
commit 23befdd13a
5 changed files with 13 additions and 9 deletions

View File

@ -28,9 +28,8 @@ func GetProjectRoot() string {
const LoaderAnimationInterval = 50
// Loader dumps a string to be displayed as a loader
func Loader() string {
func Loader(now time.Time) string {
characters := "|/-\\"
now := time.Now()
milliseconds := now.UnixMilli()
index := milliseconds / LoaderAnimationInterval % int64(len(characters))
return characters[index : index+1]