-
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.
Add support for foreign key references in partial sync
The b.intermediate collection is populated when entities are discovered in targetState, allowing for in-file foreign key references. The new `deck gateway apply` command allows you to sync partial configuration, and so must populate b.intermediate from the currentState. This results in duplicate entity errors, and so an AddIgnoringDuplicates method has been added to entities that may be a foreign key
- Loading branch information
Showing
12 changed files
with
347 additions
and
6 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
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
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,41 @@ | ||
package state | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kong/go-kong/kong" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func consumerGroupsCollection() *ConsumerGroupsCollection { | ||
return state().ConsumerGroups | ||
} | ||
|
||
func TestConsumerGroupInsert(t *testing.T) { | ||
assert := assert.New(t) | ||
collection := consumerGroupsCollection() | ||
|
||
var cg ConsumerGroup | ||
|
||
assert.NotNil(collection.Add(cg)) | ||
|
||
cg.ID = kong.String("my-id") | ||
cg.Name = kong.String("first") | ||
assert.Nil(collection.Add(cg)) | ||
|
||
// re-insert | ||
assert.NotNil(collection.Add(cg)) | ||
} | ||
|
||
func TestConsumerGroupInsertIgnoreDuplicate(t *testing.T) { | ||
assert := assert.New(t) | ||
collection := consumerGroupsCollection() | ||
|
||
var cg ConsumerGroup | ||
cg.ID = kong.String("my-id") | ||
cg.Name = kong.String("first") | ||
err := collection.Add(cg) | ||
assert.Nil(err) | ||
err = collection.AddIgnoringDuplicates(cg) | ||
assert.Nil(err) | ||
} |
Oops, something went wrong.