Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ type MyTable struct {
func (t *MyTable) ReconcilerGetAllKeys() []any {
myKeys := []MyKeyObject{}
keys := []any{}
t.col.FindMany(context.Background(), nil, &myKeys)
err := t.col.FindMany(context.Background(), nil, &myKeys)
if err != nil {
log.Panicf("MyTable: got error while fetching all keys %s", err)
}
for _, k := range myKeys {
keys = append(keys, k.Key)
}
Expand All @@ -63,7 +66,10 @@ func performMongoSetup() {
s := client.GetDataStore("test")
col := s.GetCollection("collection-reconciler")

col.DeleteMany(context.Background(), bson.D{})
_, err = col.DeleteMany(context.Background(), bson.D{})
if err != nil {
log.Panicf("Setup: failed to cleanup existing entries: %s", err)
}

key := &MyKey{
Name: "test-key-1",
Expand All @@ -79,12 +85,12 @@ func performMongoSetup() {

table = &MyTable{}
table.col = col
table.col.SetKeyType(reflect.TypeOf(&MyKey{}))
table.Initialize(context.Background(), col, table)
_ = table.col.SetKeyType(reflect.TypeOf(&MyKey{}))
_ = table.Initialize(context.Background(), col, table)
}

func tearDownMongoSetup() {
table.col.DeleteMany(context.Background(), bson.D{})
_, _ = table.col.DeleteMany(context.Background(), bson.D{})
}

type MyController struct {
Expand Down