-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Matthias Bertschy <[email protected]>
- Loading branch information
Showing
4 changed files
with
169 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package core | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSynchronizer_ObjectAddedOnServer(t *testing.T) { | ||
ctx, clientAdapter, serverAdapter := initTest(t) | ||
// add object | ||
err := serverAdapter.TestCallVerifyObject(ctx, kindKnownServers, object) | ||
assert.NoError(t, err) | ||
time.Sleep(1 * time.Second) | ||
// check object added | ||
serverObj, ok := clientAdapter.Resources[kindKnownServers.String()] | ||
assert.True(t, ok) | ||
assert.Equal(t, object, serverObj) | ||
} | ||
|
||
func TestSynchronizer_ObjectDeletedOnServer(t *testing.T) { | ||
ctx, clientAdapter, serverAdapter := initTest(t) | ||
// pre: add object | ||
clientAdapter.Resources[kindKnownServers.String()] = object | ||
serverAdapter.Resources[kindKnownServers.String()] = object | ||
// delete object | ||
err := serverAdapter.TestCallDeleteObject(ctx, kindKnownServers) | ||
assert.NoError(t, err) | ||
time.Sleep(1 * time.Second) | ||
// check object deleted | ||
_, ok := clientAdapter.Resources[kindKnownServers.String()] | ||
assert.False(t, ok) | ||
} | ||
|
||
func TestSynchronizer_ObjectModifiedOnServer(t *testing.T) { | ||
ctx, clientAdapter, serverAdapter := initTest(t) | ||
// pre: add object | ||
clientAdapter.Resources[kindKnownServers.String()] = object | ||
serverAdapter.Resources[kindKnownServers.String()] = object | ||
// modify object | ||
objectV2 := []byte(`{"kind":"kind","metadata":{"name":"name","version":"2"}}`) | ||
err := serverAdapter.TestCallVerifyObject(ctx, kindKnownServers, objectV2) | ||
assert.NoError(t, err) | ||
time.Sleep(1 * time.Second) | ||
// check object modified | ||
serverObj, ok := clientAdapter.Resources[kindKnownServers.String()] | ||
assert.True(t, ok) | ||
assert.Equal(t, objectV2, serverObj) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters