29 lines
844 B
Go
29 lines
844 B
Go
package migrations
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestSessionDisplayTitleMigration(t *testing.T) {
|
|
up, err := os.ReadFile(filepath.Join("000008_session_display_title.up.sql"))
|
|
if err != nil {
|
|
t.Fatalf("read up migration: %v", err)
|
|
}
|
|
down, err := os.ReadFile(filepath.Join("000008_session_display_title.down.sql"))
|
|
if err != nil {
|
|
t.Fatalf("read down migration: %v", err)
|
|
}
|
|
upper := strings.ToUpper(string(up))
|
|
for _, required := range []string{"ALTER TABLE SESSION_MAPPINGS", "ADD COLUMN IF NOT EXISTS DISPLAY_TITLE", "TEXT NOT NULL", "DEFAULT ''"} {
|
|
if !strings.Contains(upper, required) {
|
|
t.Errorf("up migration missing %q", required)
|
|
}
|
|
}
|
|
if !strings.Contains(strings.ToUpper(string(down)), "DROP COLUMN IF EXISTS DISPLAY_TITLE") {
|
|
t.Error("down migration must drop display_title")
|
|
}
|
|
}
|