You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-28 08:47:55 +02:00
added empty migrations template test and removed publicdir plugin
This commit is contained in:
@@ -667,7 +667,7 @@ func init() {
|
||||
|
||||
// save the changes and trigger automigrate
|
||||
if err := app.Dao().SaveCollection(collection); err != nil {
|
||||
t.Fatalf("[%d] Failed to delete dummy collection, got %v", i, err)
|
||||
t.Fatalf("[%d] Failed to save dummy collection changes, got %v", i, err)
|
||||
}
|
||||
|
||||
files, err := os.ReadDir(migrationsDir)
|
||||
@@ -695,3 +695,52 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAutomigrateCollectionNoChanges(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
lang string
|
||||
}{
|
||||
{
|
||||
migratecmd.TemplateLangJS,
|
||||
},
|
||||
{
|
||||
migratecmd.TemplateLangGo,
|
||||
},
|
||||
}
|
||||
|
||||
for i, s := range scenarios {
|
||||
app, _ := tests.NewTestApp()
|
||||
defer app.Cleanup()
|
||||
|
||||
migrationsDir := filepath.Join(app.DataDir(), "_test_migrations")
|
||||
|
||||
migratecmd.MustRegister(app, nil, &migratecmd.Options{
|
||||
TemplateLang: s.lang,
|
||||
Automigrate: true,
|
||||
Dir: migrationsDir,
|
||||
})
|
||||
|
||||
// create dummy collection
|
||||
collection := &models.Collection{}
|
||||
collection.Name = "test123"
|
||||
collection.Type = models.CollectionTypeAuth
|
||||
|
||||
// use different dao to avoid triggering automigrate while saving the dummy collection
|
||||
if err := daos.New(app.DB()).SaveCollection(collection); err != nil {
|
||||
t.Fatalf("[%d] Failed to save dummy collection, got %v", i, err)
|
||||
}
|
||||
|
||||
// @todo remove after collections cache is replaced
|
||||
app.Bootstrap()
|
||||
|
||||
// resave without changes and trigger automigrate
|
||||
if err := app.Dao().SaveCollection(collection); err != nil {
|
||||
t.Fatalf("[%d] Failed to save dummy collection update, got %v", i, err)
|
||||
}
|
||||
|
||||
files, _ := os.ReadDir(migrationsDir)
|
||||
if total := len(files); total != 0 {
|
||||
t.Fatalf("[%d] Expected 0 files to be generated, got %d", i, total)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user