mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-18 07:36:24 -07:00
Start adding pre-2021 testing
This commit is contained in:
parent
8b994dce57
commit
b34a956baa
2 changed files with 54 additions and 0 deletions
54
cmd/gochan-migration/internal/pre2021/sqlite3_test.go
Normal file
54
cmd/gochan-migration/internal/pre2021/sqlite3_test.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package pre2021
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/gochan-org/gochan/cmd/gochan-migration/internal/common"
|
||||
"github.com/gochan-org/gochan/pkg/config"
|
||||
"github.com/gochan-org/gochan/pkg/gcsql"
|
||||
"github.com/gochan-org/gochan/pkg/gcutil/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const (
|
||||
sqlite3DBPath = "tools/gochan-pre2021.sqlite3db" // relative to gochan project root
|
||||
)
|
||||
|
||||
func TestMigrateToNewDB(t *testing.T) {
|
||||
dir, err := testutil.GoToGochanRoot(t)
|
||||
if !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
if !assert.NoError(t, common.InitTestMigrationLog(t)) {
|
||||
return
|
||||
}
|
||||
dbPath := path.Join(dir, sqlite3DBPath)
|
||||
|
||||
oldSQLConfig := config.SQLConfig{
|
||||
DBtype: "sqlite3",
|
||||
DBname: path.Base(dbPath),
|
||||
DBhost: dbPath,
|
||||
DBprefix: "gc_",
|
||||
DBusername: "gochan",
|
||||
DBpassword: "password",
|
||||
}
|
||||
migrator := Pre2021Migrator{
|
||||
config: Pre2021Config{
|
||||
SQLConfig: oldSQLConfig,
|
||||
},
|
||||
}
|
||||
outDir := t.TempDir()
|
||||
|
||||
config.SetTestDBConfig("sqlite3", path.Join(outDir, "gochan-migrated.sqlite3db"), "gochan-migrated.sqlite3db", "gochan", "password", "gc_")
|
||||
sqlConfig := config.GetSQLConfig()
|
||||
|
||||
if !assert.NoError(t, gcsql.ConnectToDB(&sqlConfig)) {
|
||||
return
|
||||
}
|
||||
if !assert.NoError(t, gcsql.CheckAndInitializeDatabase("sqlite3", "4")) {
|
||||
return
|
||||
}
|
||||
|
||||
assert.NoError(t, migrator.migrateBoardsToNewDB())
|
||||
}
|
BIN
tools/gochan-pre2021.sqlite3db
Normal file
BIN
tools/gochan-pre2021.sqlite3db
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue