GitHub시작하기

API 레퍼런스는 소스 코드의 Go 문서 주석에서 추출되며 영어로 작성되어 있습니다.

package savetest

import "github.com/nsgo-dev/game/pkg/save/savetest"

개요

Package savetest provides test helpers that verify save.Game registries round-trip every registered part through a save.Store without losing or altering state.

색인

함수

func CheckRoundTrip(dir string, g *save.Game, fresh ...func() *save.Game) error

CheckRoundTrip 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) error

CheckRoundTripInto 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.