Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit tests for ImageCache syncHandler() #32

Merged
merged 1 commit into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
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
13 changes: 5 additions & 8 deletions cmd/app/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
// Convert the namespace/name string into a distinct namespace and name
namespace, name, err := cache.SplitMetaNamespaceKey(wqKey.ObjKey)
if err != nil {
runtime.HandleError(fmt.Errorf("invalid resource key: %s", wqKey.ObjKey))
return nil
glog.Errorf("Error from cache.SplitMetaNamespaceKey(): %v", err)
return err
}

glog.Infof("Starting to sync image cache %s(%s)", name, wqKey.WorkType)
Expand All @@ -427,10 +427,7 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
if err != nil {
// The ImageCache resource may no longer exist, in which case we stop
// processing.
if errors.IsNotFound(err) {
runtime.HandleError(fmt.Errorf("ImageCache '%s' in work queue no longer exists", wqKey.ObjKey))
return nil
}
glog.Errorf("Error getting imagecache(%s): %v", name, err)
return err
}

Expand All @@ -440,7 +437,7 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
status.Reason = fledgedv1alpha1.ImageCacheReasonCacheSpecValidationFailed
status.Message = err.Error()

if err = c.updateImageCacheStatus(imageCache, status); err != nil {
if err := c.updateImageCacheStatus(imageCache, status); err != nil {
glog.Errorf("Error updating imagecache status to %s: %v", status.Status, err)
return err
}
Expand All @@ -453,7 +450,7 @@ func (c *Controller) syncHandler(wqKey images.WorkQueueKey) error {
status.Reason = fledgedv1alpha1.ImageCacheReasonOldImageCacheNotFound
status.Message = fledgedv1alpha1.ImageCacheMessageOldImageCacheNotFound

if err = c.updateImageCacheStatus(imageCache, status); err != nil {
if err := c.updateImageCacheStatus(imageCache, status); err != nil {
glog.Errorf("Error updating imagecache status to %s: %v", status.Status, err)
return err
}
Expand Down
Loading