Provisioning: Do full sync on resync period when needed (#112144)

This commit is contained in:
Stephanie Hingtgen
2025-10-08 05:25:57 -06:00
committed by GitHub
parent 40dde1d4aa
commit 047c51be01
5 changed files with 152 additions and 23 deletions
@@ -303,3 +303,38 @@ func TestRepositoryController_handleDelete(t *testing.T) {
})
}
}
func TestShouldUseIncrementalSync(t *testing.T) {
versioned := repository.NewMockVersioned(t)
obj := &provisioning.Repository{
Status: provisioning.RepositoryStatus{
Sync: provisioning.SyncStatus{
LastRef: "123",
},
},
}
latestRef := "456"
t.Run("should use incremental sync", func(t *testing.T) {
versioned.On("CompareFiles", context.Background(), obj.Status.Sync.LastRef, latestRef).Return([]repository.VersionedFileChange{
{
Action: repository.FileActionDeleted,
Path: "test.json",
},
}, nil).Once()
got, err := shouldUseIncrementalSync(context.Background(), versioned, obj, latestRef)
assert.NoError(t, err)
assert.True(t, got)
})
t.Run("should not use incremental sync", func(t *testing.T) {
versioned.On("CompareFiles", context.Background(), obj.Status.Sync.LastRef, latestRef).Return([]repository.VersionedFileChange{
{
Action: repository.FileActionDeleted,
Path: "test/.keep",
},
}, nil).Once()
got, err := shouldUseIncrementalSync(context.Background(), versioned, obj, latestRef)
assert.NoError(t, err)
assert.False(t, got)
})
}