mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-19 17:50:17 +02:00
zero: resource bundle reconciler (#4445)
This commit is contained in:
parent
788376bf60
commit
3b65049d2f
18 changed files with 1560 additions and 0 deletions
95
internal/zero/reconciler/bundles_queue_test.go
Normal file
95
internal/zero/reconciler/bundles_queue_test.go
Normal file
|
@ -0,0 +1,95 @@
|
|||
package reconciler_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/zero/reconciler"
|
||||
)
|
||||
|
||||
func TestQueueSet(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
b := &reconciler.BundleQueue{}
|
||||
b.Set([]string{"bundle1", "bundle2"})
|
||||
|
||||
id1, ok1 := b.GetNextBundleToSync()
|
||||
id2, ok2 := b.GetNextBundleToSync()
|
||||
|
||||
assert.True(t, ok1, "Expected bundle1 to be set")
|
||||
assert.Equal(t, "bundle1", id1)
|
||||
assert.True(t, ok2, "Expected bundle2 to be set")
|
||||
assert.Equal(t, "bundle2", id2)
|
||||
|
||||
id3, ok3 := b.GetNextBundleToSync()
|
||||
assert.False(t, ok3, "Expected no more bundles to sync")
|
||||
assert.Empty(t, id3)
|
||||
}
|
||||
|
||||
func TestQueueMarkForSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
b := &reconciler.BundleQueue{}
|
||||
b.Set([]string{"bundle1", "bundle2"})
|
||||
|
||||
b.MarkForSync("bundle2")
|
||||
id1, ok1 := b.GetNextBundleToSync()
|
||||
|
||||
assert.True(t, ok1, "Expected bundle1 to be marked for sync")
|
||||
assert.Equal(t, "bundle1", id1)
|
||||
|
||||
b.MarkForSync("bundle3")
|
||||
id2, ok2 := b.GetNextBundleToSync()
|
||||
id3, ok3 := b.GetNextBundleToSync()
|
||||
|
||||
assert.True(t, ok2, "Expected bundle2 to be marked for sync")
|
||||
assert.Equal(t, "bundle2", id2)
|
||||
assert.True(t, ok3, "Expected bundle3 to be marked for sync")
|
||||
assert.Equal(t, "bundle3", id3)
|
||||
}
|
||||
|
||||
func TestQueueMarkForSyncLater(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
b := &reconciler.BundleQueue{}
|
||||
b.Set([]string{"bundle1", "bundle2", "bundle3"})
|
||||
|
||||
id1, ok1 := b.GetNextBundleToSync()
|
||||
b.MarkForSyncLater("bundle1")
|
||||
id2, ok2 := b.GetNextBundleToSync()
|
||||
id3, ok3 := b.GetNextBundleToSync()
|
||||
id4, ok4 := b.GetNextBundleToSync()
|
||||
id5, ok5 := b.GetNextBundleToSync()
|
||||
|
||||
assert.True(t, ok1, "Expected bundle1 to be marked for sync")
|
||||
assert.Equal(t, "bundle1", id1)
|
||||
assert.True(t, ok2, "Expected bundle2 to be marked for sync")
|
||||
assert.Equal(t, "bundle2", id2)
|
||||
assert.True(t, ok3, "Expected bundle3 to be marked for sync")
|
||||
assert.Equal(t, "bundle3", id3)
|
||||
assert.True(t, ok4, "Expected bundle1 to be marked for sync")
|
||||
assert.Equal(t, "bundle1", id4)
|
||||
assert.False(t, ok5, "Expected no more bundles to sync")
|
||||
assert.Empty(t, id5)
|
||||
|
||||
}
|
||||
|
||||
func TestQueueGetNextBundleToSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
b := &reconciler.BundleQueue{}
|
||||
b.Set([]string{"bundle1", "bundle2"})
|
||||
|
||||
id1, ok1 := b.GetNextBundleToSync()
|
||||
id2, ok2 := b.GetNextBundleToSync()
|
||||
id3, ok3 := b.GetNextBundleToSync()
|
||||
|
||||
assert.True(t, ok1, "Expected bundle1 to be retrieved for sync")
|
||||
assert.Equal(t, "bundle1", id1)
|
||||
assert.True(t, ok2, "Expected bundle2 to be retrieved for sync")
|
||||
assert.Equal(t, "bundle2", id2)
|
||||
require.False(t, ok3, "Expected no more bundles to sync")
|
||||
assert.Empty(t, id3)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue