Skip to content

Commit

Permalink
Adding tests for catalog availability
Browse files Browse the repository at this point in the history
Signed-off-by: Lalatendu Mohanty <[email protected]>
  • Loading branch information
LalatenduMohanty committed Oct 18, 2024
1 parent d320249 commit 1274c47
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions internal/controllers/core/clustercatalog_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,89 @@ func TestCatalogdControllerReconcile(t *testing.T) {
},
},
},
{
name: "catalog availability set to enable, status should get updated",
source: &MockSource{
result: &source.Result{
State: source.StateUnpacked,
FS: &fstest.MapFS{},
},
},
store: &MockStore{},
catalog: &catalogdv1alpha1.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "catalog",
Finalizers: []string{},
},
Spec: catalogdv1alpha1.ClusterCatalogSpec{
Source: catalogdv1alpha1.CatalogSource{
Type: catalogdv1alpha1.SourceTypeImage,
Image: &catalogdv1alpha1.ImageSource{
Ref: "my.org/someimage:latest",
},

Check failure on line 763 in internal/controllers/core/clustercatalog_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

unknown field ContentURL in struct literal of type "github.com/operator-framework/catalogd/api/core/v1alpha1".ClusterCatalogStatus
},
Availability: "Enabled",
},
Status: catalogdv1alpha1.ClusterCatalogStatus{
ContentURL: "URL",
LastUnpacked: metav1.Time{},
ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{
Type: catalogdv1alpha1.SourceTypeImage,
Image: &catalogdv1alpha1.ResolvedImageSource{
Ref: "",
},
},
Conditions: []metav1.Condition{
{
Type: catalogdv1alpha1.TypeServing,
Status: metav1.ConditionFalse,
Reason: catalogdv1alpha1.ReasonUnavailable,
},
{
Type: catalogdv1alpha1.TypeProgressing,
Status: metav1.ConditionFalse,
Reason: catalogdv1alpha1.ReasonDisabled,
},
},
},
},
expectedCatalog: &catalogdv1alpha1.ClusterCatalog{
ObjectMeta: metav1.ObjectMeta{
Name: "catalog",
Finalizers: []string{fbcDeletionFinalizer},
},
Spec: catalogdv1alpha1.ClusterCatalogSpec{
Source: catalogdv1alpha1.CatalogSource{
Type: catalogdv1alpha1.SourceTypeImage,
Image: &catalogdv1alpha1.ImageSource{
Ref: "my.org/someimage:latest",
},

Check failure on line 800 in internal/controllers/core/clustercatalog_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

unknown field ContentURL in struct literal of type "github.com/operator-framework/catalogd/api/core/v1alpha1".ClusterCatalogStatus (typecheck)
},
Availability: "Enabled",
},
Status: catalogdv1alpha1.ClusterCatalogStatus{
ContentURL: "URL",
ResolvedSource: &catalogdv1alpha1.ResolvedCatalogSource{
Type: catalogdv1alpha1.SourceTypeImage,
Image: &catalogdv1alpha1.ResolvedImageSource{
Ref: "",
},
},
Conditions: []metav1.Condition{
{
Type: catalogdv1alpha1.TypeServing,
Status: metav1.ConditionFalse,
Reason: catalogdv1alpha1.ReasonUnavailable,
},
{
Type: catalogdv1alpha1.TypeProgressing,
Status: metav1.ConditionFalse,
Reason: catalogdv1alpha1.ReasonDisabled,
},
},
},
},
},
} {
t.Run(tt.name, func(t *testing.T) {
reconciler := &ClusterCatalogReconciler{
Expand Down

0 comments on commit 1274c47

Please sign in to comment.