internal/chain holds typed Build, Rollout and Assignment and a Backend with no delete or purge, in memory and on the bus. The builds and rollouts buckets are asserted with history 64, no age and values up to just under a mebibyte; the assignments bucket gets the same, keeping its marker age because a stream cannot be made to disallow message ages. Migration 0104 makes the one-row chain_moved switch. The controller keeps no consolidated schema, so 0104 is the whole schema change. Nothing reads the buckets yet.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package inventory
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// **The move of the chain has a switch, made by the last migration and written by no migration** (ADR 0408 §8, issue
|
|
// 1089): migration 0104 makes the one-row table chain_moved, and does not touch a table of the chain, which a later
|
|
// delivery drops once the move is read back.
|
|
func TestMigration0104MakesTheSwitchOfTheChainsMoveAndNothingElse(t *testing.T) {
|
|
migrations, err := Migrations()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var found bool
|
|
for _, m := range migrations {
|
|
if m.Number != 104 {
|
|
continue
|
|
}
|
|
found = true
|
|
sql := strings.ToLower(m.SQL)
|
|
if !strings.Contains(sql, "create table chain_moved") || !strings.Contains(sql, "check (only_one)") {
|
|
t.Errorf("migration 0104 does not make the one-row chain_moved:\n%s", m.SQL)
|
|
}
|
|
for _, line := range strings.Split(sql, "\n") {
|
|
if strings.HasPrefix(strings.TrimSpace(line), "--") {
|
|
continue
|
|
}
|
|
for _, verb := range []string{"drop ", "insert ", "delete ", "update ", "alter "} {
|
|
if strings.Contains(line, verb) {
|
|
t.Errorf("migration 0104 does more than make the switch: %q", line)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("no migration 0104")
|
|
}
|
|
}
|