Skip to content

Commit a9c3fb1

Browse files
gaultierory-bot
authored andcommitted
chore: add migration tests in kratos non-oss for crdb
GitOrigin-RevId: d94d8a0ac9c722c665caff84a971d8b247f5f340
1 parent 7cec59e commit a9c3fb1

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

oryx/popx/migration_box.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func WithTestdata(t *testing.T, testdata fs.FS) MigrationBoxOption {
9191
if err != nil {
9292
return err
9393
}
94-
if info.IsDir() {
94+
if !info.Type().IsRegular() {
95+
t.Logf("skipping testdata entry that is not a file: %s", path)
9596
return nil
9697
}
9798

oryx/popx/migrator.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
164164

165165
reverted := 0
166166
defer func() {
167-
mb.l.Debugf("Successfully reverted %d migrations.", reverted)
167+
migrationsToRevertCount := min(steps, len(mfs))
168+
mb.l.Debugf("Successfully reverted %d/%d migrations.", reverted, migrationsToRevertCount)
168169
if err != nil {
169170
mb.l.WithError(err).Error("Problem reverting migrations.")
170171
}
@@ -174,6 +175,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
174175
break
175176
}
176177
l := mb.l.WithField("version", mi.Version).WithField("migration_name", mi.Name).WithField("migration_file", mi.Path)
178+
l.Debugf("handling migration %s", mi.Name)
177179
exists, err := c.Where("version = ?", mi.Version).Exists(mtn)
178180
if err != nil {
179181
return errors.Wrapf(err, "problem checking for migration version %s", mi.Version)
@@ -194,7 +196,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
194196
}
195197

196198
if err := mi.Valid(); err != nil {
197-
return err
199+
return errors.WithStack(err)
198200
}
199201

200202
if mb.shouldNotUseTransaction(mi) {
@@ -211,7 +213,7 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
211213
if err := mb.isolatedTransaction(ctx, "down", func(conn *pop.Connection) error {
212214
err := mi.Runner(mi, conn)
213215
if err != nil {
214-
return err
216+
return errors.WithStack(err)
215217
}
216218

217219
// #nosec G201 - mtn is a system-wide const
@@ -221,11 +223,11 @@ func (mb *MigrationBox) Down(ctx context.Context, steps int) (err error) {
221223

222224
return nil
223225
}); err != nil {
224-
return err
226+
return errors.WithStack(err)
225227
}
226228
}
227229

228-
l.Infof("< %s applied successfully", mi.Name)
230+
l.Infof("%s applied successfully", mi.Name)
229231
reverted++
230232
}
231233
return nil

oryx/randx/strength/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
2727
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2828
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
2929
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
30-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
31-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
30+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
31+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
3232
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
3333
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
3434
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

0 commit comments

Comments
 (0)