clean up test a little and add some error checking

This commit is contained in:
Amber Brown 2020-07-01 17:02:19 +10:00
Родитель 74671524e7
Коммит 53dea9afd8
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -144,15 +144,23 @@ func TestAddResourceProviderVersion(t *testing.T) {
openshiftClusters.EXPECT().
PatchWithLease(gomock.Any(), clusterdoc.Key, gomock.Any()).
DoAndReturn(func(ctx context.Context, key string, f func(doc *api.OpenShiftClusterDocument) error) (*api.OpenShiftClusterDocument, error) {
// Load what the database would have right now
docFromDatabase := &api.OpenShiftClusterDocument{}
json.Unmarshal(databaseDoc, &docFromDatabase)
err := f(docFromDatabase)
if err != nil {
t.Error("PatchWithLease failed")
return nil, err
}
// Save what would be stored in the db
databaseDoc, _ = json.Marshal(docFromDatabase)
databaseDoc, err = json.Marshal(docFromDatabase)
if err != nil {
t.Error("Failed serialisation")
return nil, err
}
return docFromDatabase, err
})
@ -161,9 +169,9 @@ func TestAddResourceProviderVersion(t *testing.T) {
db: openshiftClusters,
}
err := i.addResourceProviderVersion(ctx)
if err != nil {
t.Error(err)
return
}
// Check it was set to the correct value in the database