sync
This commit is contained in:
parent
0fa1de3b4e
commit
a755b4d2c8
6 changed files with 59 additions and 15 deletions
|
@ -10,23 +10,25 @@ import (
|
|||
"github.com/genudine/saerro-go/types"
|
||||
)
|
||||
|
||||
func getEventHandlerTestShim(t *testing.T) (EventHandler, context.Context, *storemock.MockPlayerStore) {
|
||||
func getEventHandlerTestShim(t *testing.T) (EventHandler, context.Context, *storemock.MockPlayerStore, *storemock.MockVehicleStore) {
|
||||
t.Helper()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
|
||||
t.Cleanup(cancel)
|
||||
|
||||
ps := new(storemock.MockPlayerStore)
|
||||
vs := new(storemock.MockVehicleStore)
|
||||
|
||||
return EventHandler{
|
||||
Ingest: &ingest.Ingest{
|
||||
PlayerStore: ps,
|
||||
PlayerStore: ps,
|
||||
VehicleStore: vs,
|
||||
},
|
||||
}, ctx, ps
|
||||
}, ctx, ps, vs
|
||||
}
|
||||
|
||||
func TestHandleDeath(t *testing.T) {
|
||||
eh, ctx, ps := getEventHandlerTestShim(t)
|
||||
eh, ctx, ps, _ := getEventHandlerTestShim(t)
|
||||
|
||||
event := types.ESSEvent{
|
||||
EventName: "Death",
|
||||
|
@ -52,7 +54,7 @@ func TestHandleDeath(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHandleExperience(t *testing.T) {
|
||||
eh, ctx, ps := getEventHandlerTestShim(t)
|
||||
eh, ctx, ps, vs := getEventHandlerTestShim(t)
|
||||
|
||||
event := types.ESSEvent{
|
||||
EventName: "GainExperience",
|
||||
|
@ -66,14 +68,17 @@ func TestHandleExperience(t *testing.T) {
|
|||
ExperienceID: 674,
|
||||
}
|
||||
|
||||
p := types.PopEventFromESSEvent(event, false).ToPlayer()
|
||||
ps.On("Insert", ctx, p).Return(nil)
|
||||
p := types.PopEventFromESSEvent(event, false)
|
||||
v := p.ToVehicle()
|
||||
v.VehicleName = "ant" // exp event translation
|
||||
ps.On("Insert", ctx, p.ToPlayer()).Return(nil)
|
||||
vs.On("Insert", ctx, v).Return(nil)
|
||||
|
||||
eh.HandleExperience(ctx, event)
|
||||
}
|
||||
|
||||
func TestHandleAnalytics(t *testing.T) {
|
||||
eh, ctx, _ := getEventHandlerTestShim(t)
|
||||
eh, ctx, _, _ := getEventHandlerTestShim(t)
|
||||
event := types.ESSEvent{
|
||||
EventName: "GainExperience",
|
||||
WorldID: 17,
|
||||
|
@ -90,7 +95,7 @@ func TestHandleAnalytics(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHandleEvent(t *testing.T) {
|
||||
eh, ctx, ps := getEventHandlerTestShim(t)
|
||||
eh, ctx, ps, vs := getEventHandlerTestShim(t)
|
||||
|
||||
events := []types.ESSEvent{
|
||||
{
|
||||
|
@ -124,11 +129,18 @@ func TestHandleEvent(t *testing.T) {
|
|||
|
||||
p1 := types.PopEventFromESSEvent(events[0], false).ToPlayer()
|
||||
ps.On("Insert", ctx, p1).Return(nil).Once()
|
||||
|
||||
p2 := types.PopEventFromESSEvent(events[0], true).ToPlayer()
|
||||
ps.On("Insert", ctx, p2).Return(nil).Once()
|
||||
p3 := types.PopEventFromESSEvent(events[1], false).ToPlayer()
|
||||
|
||||
e3 := types.PopEventFromESSEvent(events[1], false)
|
||||
p3 := e3.ToPlayer()
|
||||
ps.On("Insert", ctx, p3).Return(nil).Once()
|
||||
|
||||
v3 := types.PopEventFromESSEvent(events[1], false).ToVehicle()
|
||||
v3.VehicleName = "galaxy" // exp event translation
|
||||
vs.On("Insert", ctx, v3).Return(nil).Once()
|
||||
|
||||
for _, event := range events {
|
||||
eh.HandleEvent(ctx, event)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func TestTrackPopHappyPath(t *testing.T) {
|
|||
TeamID: types.TR,
|
||||
LoadoutID: 4,
|
||||
ClassName: translators.CombatMedic,
|
||||
VehicleName: "unknown",
|
||||
CharacterID: "aaaa",
|
||||
}
|
||||
|
||||
|
@ -57,6 +58,7 @@ func TestTrackPopFixup(t *testing.T) {
|
|||
ZoneID: 4,
|
||||
TeamID: 0,
|
||||
ClassName: "unknown",
|
||||
VehicleName: "unknown",
|
||||
CharacterID: "bbbb",
|
||||
}
|
||||
pastEventPlayer := event.ToPlayer()
|
||||
|
@ -77,6 +79,7 @@ func TestTrackPopFixupFailed(t *testing.T) {
|
|||
ZoneID: 4,
|
||||
TeamID: 0,
|
||||
ClassName: "unknown",
|
||||
VehicleName: "unknown",
|
||||
CharacterID: "bbbb",
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue