timflannagan / rukpak

Rukpak runs in a Kubernetes cluster and defines an API for installing cloud native bundle content
Apache License 2.0
0 stars 0 forks source link

add support for annotations #57

Open github-actions[bot] opened 2 years ago

github-actions[bot] commented 2 years ago

https://github.com/timflannagan/rukpak/blob/0a96488ba21f33bb012eb7e93953d2fdc3c6280d/internal/util/util_test.go#L107


package util

import (
    "testing"

    metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

    "github.com/operator-framework/rukpak/api/v1alpha1"
    rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
    plain "github.com/operator-framework/rukpak/internal/provisioner/plain/types"
)

func TestCheckDesiredBundleTemplate(t *testing.T) {
    sampleSpec := v1alpha1.BundleSpec{
        ProvisionerClassName: plain.ProvisionerID,
        Source: rukpakv1alpha1.BundleSource{
            Type: rukpakv1alpha1.SourceTypeImage,
            Image: &rukpakv1alpha1.ImageSource{
                Ref: "non-existent",
            },
        },
    }
    type args struct {
        existingBundle *rukpakv1alpha1.Bundle
        desiredBundle  *rukpakv1alpha1.BundleTemplate
    }
    tests := []struct {
        name string
        args args
        want bool
    }{
        {
            name: "True/BundleMatchesTemplate",
            args: args{
                existingBundle: &rukpakv1alpha1.Bundle{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: sampleSpec,
                },
                desiredBundle: &rukpakv1alpha1.BundleTemplate{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: sampleSpec,
                },
            },
            want: true,
        },
        {
            name: "False/SpecDiffers",
            args: args{
                existingBundle: &rukpakv1alpha1.Bundle{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: rukpakv1alpha1.BundleSpec{
                        ProvisionerClassName: "non-existent-provisioner-class-name",
                    },
                },
                desiredBundle: &rukpakv1alpha1.BundleTemplate{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: sampleSpec,
                },
            },
            want: false,
        },
        {
            name: "False/LabelsDiffer",
            args: args{
                existingBundle: &rukpakv1alpha1.Bundle{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: sampleSpec,
                },
                desiredBundle: &rukpakv1alpha1.BundleTemplate{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "different-value",
                        },
                    },
                    Spec: sampleSpec,
                },
            },
            want: false,
        },
        {
            // TODO: add support for annotations
            name: "True/AnnotationsDiffer",
            args: args{
                existingBundle: &rukpakv1alpha1.Bundle{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                        Annotations: map[string]string{
                            "stub": "stub",
                        },
                    },
                    Spec: sampleSpec,
                },
                desiredBundle: &rukpakv1alpha1.BundleTemplate{
                    ObjectMeta: metav1.ObjectMeta{
                        Name: "stub",
                        Labels: map[string]string{
                            "stub": "stub",
                        },
                        Annotations: map[string]string{},
                    },
                    Spec: sampleSpec,
                },
            },
            want: true,
        },
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            if got := CheckDesiredBundleTemplate(tt.args.existingBundle, tt.args.desiredBundle); got != tt.want {
                t.Errorf("CheckDesiredBundleTemplate() = %v, want %v", got, tt.want)
            }
        })
    }
}
github-actions[bot] commented 1 year ago

This issue has become stale because it has been open 60 days with no activity. The maintainers of this repo will remove this label during issue triage or it will be removed automatically after an update. Adding the lifecycle/frozen label will cause this issue to ignore lifecycle events.