mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Some checks failed
CodeQL / codeql (push) Has been cancelled
Docker Build / docker-build (push) Has been cancelled
Gateway Conformance / gateway-conformance (push) Has been cancelled
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Has been cancelled
Go Build / go-build (push) Has been cancelled
Go Check / go-check (push) Has been cancelled
Go Lint / go-lint (push) Has been cancelled
Go Test / go-test (push) Has been cancelled
Interop / interop-prep (push) Has been cancelled
Sharness / sharness-test (push) Has been cancelled
Spell Check / spellcheck (push) Has been cancelled
Interop / helia-interop (push) Has been cancelled
Interop / ipfs-webui (push) Has been cancelled
https://github.com/ipfs/kubo/pull/10883 https://github.com/ipshipyard/config.ipfs-mainnet.org/issues/3 --------- Co-authored-by: gammazero <gammazero@users.noreply.github.com>
37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package migrations
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestHasEmbeddedMigration(t *testing.T) {
|
|
// Test that the 16-to-17 migration is registered
|
|
assert.True(t, HasEmbeddedMigration("fs-repo-16-to-17"),
|
|
"fs-repo-16-to-17 migration should be registered")
|
|
|
|
// Test that a non-existent migration is not found
|
|
assert.False(t, HasEmbeddedMigration("fs-repo-99-to-100"),
|
|
"fs-repo-99-to-100 migration should not be registered")
|
|
}
|
|
|
|
func TestEmbeddedMigrations(t *testing.T) {
|
|
// Test that we have at least one embedded migration
|
|
assert.NotEmpty(t, embeddedMigrations, "No embedded migrations found")
|
|
|
|
// Test that all registered migrations implement the interface
|
|
for name, migration := range embeddedMigrations {
|
|
assert.NotEmpty(t, migration.Versions(),
|
|
"Migration %s has empty versions", name)
|
|
}
|
|
}
|
|
|
|
func TestRunEmbeddedMigration(t *testing.T) {
|
|
// Test that running a non-existent migration returns an error
|
|
err := RunEmbeddedMigration(context.Background(), "non-existent", "/tmp", false)
|
|
require.Error(t, err, "Expected error for non-existent migration")
|
|
}
|