forked from operator-framework/operator-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use a type to protect migration interactions
Signed-off-by: Jordan Keister <jordan@nimblewidget.com>
- Loading branch information
Showing
14 changed files
with
315 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package migrations | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/operator-framework/operator-registry/alpha/declcfg" | ||
) | ||
|
||
func TestMigrations(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
migrator Migration | ||
expectedResult error | ||
}{ | ||
{ | ||
name: "NoMigrations", | ||
migrator: newMigration(NoMigrations, "do nothing", func(_ *declcfg.DeclarativeConfig) error { return nil }), | ||
expectedResult: nil, | ||
}, | ||
{ | ||
name: "BundleObjectToCSVMetadata", | ||
migrator: newMigration("bundle-object-to-csv-metadata", `migrates bundles' "olm.bundle.object" to "olm.csv.metadata"`, bundleObjectToCSVMetadata), | ||
expectedResult: nil, // Replace with the expected result for this migration | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
config := &declcfg.DeclarativeConfig{} // Replace with your actual config | ||
|
||
err := test.migrator.Migrate(config) | ||
if err != test.expectedResult { | ||
t.Errorf("Expected error: %v, but got: %v", test.expectedResult, err) | ||
} | ||
|
||
// Add additional success criteria evaluation between each migration's execution if needed | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.