Image input
This commit is contained in:
@@ -156,6 +156,44 @@ func TestMigrateRunsMigrationAddedBeforeApplied(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlobsMigrationOverPositionalCopy(t *testing.T) {
|
||||
db := openTestDB(t, filepath.Join(t.TempDir(), "byre.db"))
|
||||
err := migrate(db, migrations[:9])
|
||||
if err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
insertReport(t, db, "r1", `{"text":"x"}`)
|
||||
_, err = db.Exec(`
|
||||
CREATE TABLE blobs (id TEXT PRIMARY KEY, content_type TEXT NOT NULL, path TEXT NOT NULL, created_by TEXT NOT NULL REFERENCES users(login), created_at TEXT NOT NULL);
|
||||
INSERT INTO blobs VALUES ('b1', 'image/png', 'blobs/b1', 'alice', 'x');
|
||||
ALTER TABLE turn_queue ADD COLUMN images TEXT NOT NULL DEFAULT '[]';
|
||||
INSERT INTO turn_queue (session_id, actor, text, created_at) VALUES ('s1', 'alice', 'queued', 'x');
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatalf("positional copy: %v", err)
|
||||
}
|
||||
|
||||
err = migrate(db, migrations)
|
||||
if err != nil {
|
||||
t.Fatalf("migrate: %v", err)
|
||||
}
|
||||
|
||||
text := ""
|
||||
images := ""
|
||||
err = db.QueryRow(`SELECT text, images FROM turn_queue WHERE session_id = 's1'`).Scan(&text, &images)
|
||||
if err != nil {
|
||||
t.Fatalf("queued turn: %v", err)
|
||||
}
|
||||
if text != "queued" || images != "[]" {
|
||||
t.Fatalf("queued turn %q %q", text, images)
|
||||
}
|
||||
blobs := 0
|
||||
err = db.QueryRow(`SELECT count(*) FROM blobs`).Scan(&blobs)
|
||||
if err != nil || blobs != 1 {
|
||||
t.Fatalf("blobs %d: %v", blobs, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlattenReportPayloadsRunsTwice(t *testing.T) {
|
||||
db := openTestDB(t, filepath.Join(t.TempDir(), "byre.db"))
|
||||
err := migrate(db, migrations)
|
||||
|
||||
Reference in New Issue
Block a user