diff --git a/utils/cliutils/persistence.go b/utils/cliutils/persistence.go index d74cc3e0c..45383c6be 100644 --- a/utils/cliutils/persistence.go +++ b/utils/cliutils/persistence.go @@ -33,8 +33,8 @@ func init() { persistenceFilePath = filepath.Join(homeDir, persistenceFileName) } -// SetCliLatestVersionCheckTime updates the latest version check time in the persistence file -func SetCliLatestVersionCheckTime(timestamp int64) error { +// setCliLatestVersionCheckTime updates the latest version check time in the persistence file +func setCliLatestVersionCheckTime(timestamp int64) error { fileLock.Lock() defer fileLock.Unlock() @@ -47,8 +47,8 @@ func SetCliLatestVersionCheckTime(timestamp int64) error { return setPersistenceInfo(info) } -// GetLatestCliVersionCheckTime retrieves the latest version check time from the persistence file -func GetLatestCliVersionCheckTime() (*int64, error) { +// getLatestCliVersionCheckTime retrieves the latest version check time from the persistence file +func getLatestCliVersionCheckTime() (*int64, error) { fileLock.Lock() defer fileLock.Unlock() diff --git a/utils/cliutils/persistence_test.go b/utils/cliutils/persistence_test.go index 842d89d90..cdf5826e7 100644 --- a/utils/cliutils/persistence_test.go +++ b/utils/cliutils/persistence_test.go @@ -16,11 +16,11 @@ func TestSetAndGetLatestVersionCheckTime(t *testing.T) { // Set the timestamp timestamp := time.Now().UnixMilli() - err := SetCliLatestVersionCheckTime(timestamp) + err := setCliLatestVersionCheckTime(timestamp) assert.NoError(t, err, "Failed to set LatestCliVersionCheckTime") // Get the timestamp - storedTimestamp, err := GetLatestCliVersionCheckTime() + storedTimestamp, err := getLatestCliVersionCheckTime() assert.NoError(t, err, "Failed to get LatestCliVersionCheckTime") // Assert equality @@ -56,7 +56,7 @@ func TestPersistenceFileCreation(t *testing.T) { // Trigger file creation by setting version check time timestamp := time.Now().UnixMilli() - err = SetCliLatestVersionCheckTime(timestamp) + err = setCliLatestVersionCheckTime(timestamp) assert.NoError(t, err, "Failed to set LatestCliVersionCheckTime") // Verify the persistence file was created diff --git a/utils/cliutils/utils.go b/utils/cliutils/utils.go index 3f49eb0c2..26b2126f7 100644 --- a/utils/cliutils/utils.go +++ b/utils/cliutils/utils.go @@ -701,7 +701,7 @@ func shouldCheckLatestCliVersion() (shouldCheck bool, err error) { if strings.ToLower(os.Getenv(JfrogCliAvoidNewVersionWarning)) == "true" { return } - latestVersionCheckTime, err := GetLatestCliVersionCheckTime() + latestVersionCheckTime, err := getLatestCliVersionCheckTime() if err != nil { return } @@ -711,7 +711,7 @@ func shouldCheckLatestCliVersion() (shouldCheck bool, err error) { // Timestamp file exists and updated less than 6 hours ago, therefor no need to check version again return } - if err = SetCliLatestVersionCheckTime(timeNow); err != nil { + if err = setCliLatestVersionCheckTime(timeNow); err != nil { return } return true, nil diff --git a/utils/cliutils/utils_test.go b/utils/cliutils/utils_test.go index 88581d99a..f9bf32b2e 100644 --- a/utils/cliutils/utils_test.go +++ b/utils/cliutils/utils_test.go @@ -134,7 +134,7 @@ func TestShouldCheckLatestCliVersion(t *testing.T) { assert.NoError(t, err) assert.False(t, shouldCheck) - assert.NoError(t, SetCliLatestVersionCheckTime(time.Now().UnixMilli()-LatestCliVersionCheckInterval.Milliseconds())) + assert.NoError(t, setCliLatestVersionCheckTime(time.Now().UnixMilli()-LatestCliVersionCheckInterval.Milliseconds())) // Third run, more than 6 hours between runs, so should return true shouldCheck, err = shouldCheckLatestCliVersion() assert.NoError(t, err)