Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions acceleration/internal/store/datamove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ package store

import (
"context"
cryptorand "crypto/rand"
"database/sql"
"encoding/hex"
"encoding/json"
"fmt"
"maps"
"math/big"
"math/rand/v2"
"net/url"
"os"
Expand Down Expand Up @@ -3695,6 +3697,29 @@ func (s *DataMoveSuite) TestARequestMovedOnFromACopyIsOneRowWhereverItLands() {
s.Len(s.requestsByUsage(), 1, "a copy of a copy is the copy already here")
}

func (s *DataMoveSuite) TestARequestMovedOnTwiceAndBackIsOneRowWhereItWasRecorded() {
id, err := cryptorand.Int(cryptorand.Reader, big.NewInt(1_000_000_000_000))
s.Require().NoError(err)
home := s.takenRequest(s.source, id.Int64())
s.move("acme", "acme")

// A third holder: the destination's copy, sent on to another customer there.
for _, row := range s.exportFrom(s.destination, "acme").of("requests") {
encoded, err := json.Marshal(row)
s.Require().NoError(err)
s.Require().NoError(s.destination.ImportRow(s.ctx, "globex", "requests", encoded))
}
for _, row := range s.exportFrom(s.destination, "globex").of("requests") {
encoded, err := json.Marshal(row)
s.Require().NoError(err)
s.Require().NoError(s.source.ImportRow(s.ctx, "acme", "requests", encoded))
}

rows := s.exportFrom(s.source, "acme").of("requests")
s.Require().Len(rows, 1, "a copy of a copy of a copy is the row it was copied from")
s.Equal(home.UsageID.String(), rows[0]["usage_id"])
}

// drewNothing restarts the sequence behind a column, so the store has drawn nothing from it yet.
// A truncate leaves sequences where they were, and the databases outlive a run.
func (s *DataMoveSuite) drewNothing(store *Store, table, column string) {
Expand Down
Loading