test: add pet fusion transaction coverage
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
50
modules/player/service/pet_fusion_tx_test.go
Normal file
50
modules/player/service/pet_fusion_tx_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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")
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user