Files
bl/modules/player/service/pet_fusion_tx_test.go
xinian 3cfde577eb
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
test: add pet fusion transaction coverage
2026-04-16 09:21:39 +08:00

51 lines
1.2 KiB
Go

package service
import (
"blazing/modules/player/model"
"testing"
)
func TestFindPetDataSnapshotInPlayerInfo(t *testing.T) {
t.Run("pet list", func(t *testing.T) {
want := model.PetInfo{CatchTime: 1001, Level: 55}
info := model.PlayerInfo{
PetList: []model.PetInfo{want},
}
got, ok := findPetDataSnapshotInPlayerInfo(info, want.CatchTime)
if !ok {
t.Fatal("expected pet snapshot in pet list")
}
if got.CatchTime != want.CatchTime || got.Level != want.Level {
t.Fatalf("unexpected pet snapshot: %+v", got)
}
})
t.Run("backup pet list", func(t *testing.T) {
want := model.PetInfo{CatchTime: 2002, Level: 66}
info := model.PlayerInfo{
BackupPetList: []model.PetInfo{want},
}
got, ok := findPetDataSnapshotInPlayerInfo(info, want.CatchTime)
if !ok {
t.Fatal("expected pet snapshot in backup pet list")
}
if got.CatchTime != want.CatchTime || got.Level != want.Level {
t.Fatalf("unexpected pet snapshot: %+v", got)
}
})
t.Run("not found", func(t *testing.T) {
info := model.PlayerInfo{
PetList: []model.PetInfo{{CatchTime: 3003}},
BackupPetList: []model.PetInfo{{CatchTime: 4004}},
}
_, ok := findPetDataSnapshotInPlayerInfo(info, 9999)
if ok {
t.Fatal("expected missing pet snapshot")
}
})
}