add more tests to check pkg manifest
@@ -16,10 +16,10 @@ package olmcatalog
import (
"path/filepath"
+ "reflect"
"testing"
"github.com/operator-framework/operator-registry/pkg/registry"
-
gen "github.com/operator-framework/operator-sdk/internal/generate/gen"
"github.com/stretchr/testify/assert"
@@ -112,6 +112,62 @@ func TestValidatePackageManifest(t *testing.T) {
}
}
+func TestNewPackageManifest(t *testing.T) {
+ type args struct {
+ operatorName string
+ channelName string
+ version string
+ }
+ tests := []struct {
+ name string
+ args args
+ want registry.PackageManifest
+ }{
+ {
+ name: "Should return a valid registry.PackageManifest",
+ want: registry.PackageManifest{
+ PackageName: "memcached-operator",
+ Channels: []registry.PackageChannel{
+ registry.PackageChannel{
+ Name: "stable",
+ CurrentCSVName: "memcached-operator.v0.0.3",
+ },
+ },
+ DefaultChannelName: "stable",
+ },
+ args: args{
+ operatorName: testProjectName,
+ channelName: "stable",
+ version: csvVersion,
+ },
+ },
+ {
+ name: "Should return a valid registry.PackageManifest with channel == alpha when it is not informed",
+ want: registry.PackageManifest{
+ PackageName: "memcached-operator",
+ Channels: []registry.PackageChannel{
+ registry.PackageChannel{
+ Name: "alpha",
+ CurrentCSVName: "memcached-operator.v0.0.3",
+ },
+ },
+ DefaultChannelName: "alpha",
+ },
+ args: args{
+ operatorName: testProjectName,
+ version: csvVersion,
+ },
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := newPackageManifest(tt.args.operatorName, tt.args.channelName, tt.args.version); !reflect.DeepEqual(got, tt.want) {
+ t.Errorf("NewPackageManifest() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
const packageManifestExp = `channels:
- currentCSV: memcached-operator.v0.0.2
name: alpha
