A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.
package savetest
import "github.com/nsgo-dev/game/pkg/save/savetest"Visão geral
Package savetest provides test helpers that verify save.Game registries round-trip every registered part through a save.Store without losing or altering state.
Índice
Funções
func CheckRoundTrip(dir string, g *save.Game, fresh ...func() *save.Game) errorCheckRoundTrip performs the same verification as RoundTrip using dir as the temporary store directory and returns an error instead of failing a testing.TB.
func CheckRoundTripInto(dir string, src, dst *save.Game) errorCheckRoundTripInto saves src into dir, loads the saved slot into dst, verifies both games register the same parts and versions, and checks that every part's JSON state matches.
func RoundTrip(t testing.TB, g *save.Game, fresh ...func() *save.Game)RoundTrip saves g to a temporary save.Store, loads the slot back into a fresh *save.Game, and compares every registered part's serialized state before and after the load.
Pass a fresh factory (func() *save.Game) to load into a newly constructed game instance and catch parts whose LoadState is a no-op or fails to restore state. When fresh is omitted, RoundTrip resets any registered parts that implement save.Resetter on g before loading back into g.
func RoundTripInto(t testing.TB, src, dst *save.Game)RoundTripInto saves src to a temporary save.Store, loads the slot into dst, and compares every registered part's serialized state between src and dst.