Skip to content

Commit

Permalink
tests: move getApl func to helper file
Browse files Browse the repository at this point in the history
Signed-off-by: jarves <jarveson@gmail.com>
  • Loading branch information
jarveson committed Oct 6, 2023
1 parent 933cfe0 commit b2b0d09
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 252 deletions.
11 changes: 11 additions & 0 deletions sim/core/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"log"
"os"
"testing"

"github.com/wowsims/wotlk/sim/core/proto"
Expand Down Expand Up @@ -234,3 +235,13 @@ func RaidBenchmark(b *testing.B, rsr *proto.RaidSimRequest) {
}
}
}

func GetAplRotation(dir string, file string) RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return RotationCombo{Label: file, Rotation: APLRotationFromJsonString(string(data))}
}
28 changes: 8 additions & 20 deletions sim/deathknight/dps/dps_deathknight_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dps

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common" // imported to get item effects included.
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterDpsDeathknight()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestBlood(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassDeathknight,
Expand All @@ -36,8 +24,8 @@ func TestBlood(t *testing.T) {
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsBlood},
OtherRotations: []core.RotationCombo{
GetAplRotation("../../../ui/deathknight/apls", "blood_pesti"),
GetAplRotation("../../../ui/deathknight/apls", "blood_pesti_dd"),
core.GetAplRotation("../../../ui/deathknight/apls", "blood_pesti"),
core.GetAplRotation("../../../ui/deathknight/apls", "blood_pesti_dd"),
},

ItemFilter: ItemFilter,
Expand All @@ -57,9 +45,9 @@ func TestUnholy(t *testing.T) {
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsUnholy},

OtherRotations: []core.RotationCombo{
GetAplRotation("../../../ui/deathknight/apls", "uh_2h_ss"),
GetAplRotation("../../../ui/deathknight/apls", "uh_dnd_aoe"),
GetAplRotation("../../../ui/deathknight/apls", "unholy_dw_ss"),
core.GetAplRotation("../../../ui/deathknight/apls", "uh_2h_ss"),
core.GetAplRotation("../../../ui/deathknight/apls", "uh_dnd_aoe"),
core.GetAplRotation("../../../ui/deathknight/apls", "unholy_dw_ss"),
},

ItemFilter: ItemFilter,
Expand All @@ -82,8 +70,8 @@ func TestFrost(t *testing.T) {
},

OtherRotations: []core.RotationCombo{
GetAplRotation("../../../ui/deathknight/apls", "frost_bl_pesti"),
GetAplRotation("../../../ui/deathknight/apls", "frost_uh_pesti"),
core.GetAplRotation("../../../ui/deathknight/apls", "frost_bl_pesti"),
core.GetAplRotation("../../../ui/deathknight/apls", "frost_uh_pesti"),
},

ItemFilter: ItemFilter,
Expand All @@ -102,7 +90,7 @@ func TestFrostUH(t *testing.T) {
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsFrost},
OtherRotations: []core.RotationCombo{
GetAplRotation("../../../ui/deathknight/apls", "frost_uh_pesti"),
core.GetAplRotation("../../../ui/deathknight/apls", "frost_uh_pesti"),
},

ItemFilter: ItemFilter,
Expand Down
16 changes: 2 additions & 14 deletions sim/deathknight/tank/tank_deathknight_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tank

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common" // imported to get item effects included.
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterTankDeathknight()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestBloodTank(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassDeathknight,
Expand All @@ -35,9 +23,9 @@ func TestBloodTank(t *testing.T) {
Glyphs: Glyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsBloodTank},
Rotation: GetAplRotation("../../../ui/tank_deathknight/apls", "blood_icy_touch"),
Rotation: core.GetAplRotation("../../../ui/tank_deathknight/apls", "blood_icy_touch"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../../ui/tank_deathknight/apls", "blood_aggro"),
core.GetAplRotation("../../../ui/tank_deathknight/apls", "blood_aggro"),
},

IsTank: true,
Expand Down
16 changes: 2 additions & 14 deletions sim/druid/balance/balance_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package balance

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common" // imported to get caster sets included. (we use spellfire here)
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterBalanceDruid()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestBalance(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassDruid,
Expand All @@ -39,7 +27,7 @@ func TestBalance(t *testing.T) {
Glyphs: StandardGlyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Default", SpecOptions: PlayerOptionsAdaptive},
Rotation: GetAplRotation("../../../ui/balance_druid/apls", "basic_p3"),
Rotation: core.GetAplRotation("../../../ui/balance_druid/apls", "basic_p3"),

ItemFilter: ItemFilter,
}))
Expand All @@ -59,7 +47,7 @@ func TestBalancePhase3(t *testing.T) {
},
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Default", SpecOptions: PlayerOptionsAdaptive},
Rotation: GetAplRotation("../../../ui/balance_druid/apls", "basic_p3"),
Rotation: core.GetAplRotation("../../../ui/balance_druid/apls", "basic_p3"),

ItemFilter: core.ItemFilter{
WeaponTypes: []proto.WeaponType{
Expand Down
14 changes: 1 addition & 13 deletions sim/druid/tank/tank_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package tank

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common"
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterFeralTankDruid()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestFeralTank(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassDruid,
Expand All @@ -34,7 +22,7 @@ func TestFeralTank(t *testing.T) {
Glyphs: StandardGlyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Default", SpecOptions: PlayerOptionsDefault},
Rotation: GetAplRotation("../../../ui/feral_tank_druid/apls", "default"),
Rotation: core.GetAplRotation("../../../ui/feral_tank_druid/apls", "default"),

IsTank: true,
InFrontOfTarget: true,
Expand Down
24 changes: 6 additions & 18 deletions sim/hunter/hunter_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package hunter

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common" // imported to get item effects included.
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterHunter()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestBM(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassHunter,
Expand All @@ -35,7 +23,7 @@ func TestBM(t *testing.T) {
Glyphs: BMGlyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsBasic},
Rotation: GetAplRotation("../../ui/hunter/apls", "bm"),
Rotation: core.GetAplRotation("../../ui/hunter/apls", "bm"),

ItemFilter: ItemFilter,
}))
Expand All @@ -52,9 +40,9 @@ func TestMM(t *testing.T) {
Glyphs: MMGlyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsBasic},
Rotation: GetAplRotation("../../ui/hunter/apls", "mm"),
Rotation: core.GetAplRotation("../../ui/hunter/apls", "mm"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../ui/hunter/apls", "mm_advanced"),
core.GetAplRotation("../../ui/hunter/apls", "mm_advanced"),
},

ItemFilter: ItemFilter,
Expand All @@ -72,10 +60,10 @@ func TestSV(t *testing.T) {
Glyphs: SVGlyphs,
Consumes: FullConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Basic", SpecOptions: PlayerOptionsBasic},
Rotation: GetAplRotation("../../ui/hunter/apls", "sv"),
Rotation: core.GetAplRotation("../../ui/hunter/apls", "sv"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../ui/hunter/apls", "sv_advanced"),
GetAplRotation("../../ui/hunter/apls", "aoe"),
core.GetAplRotation("../../ui/hunter/apls", "sv_advanced"),
core.GetAplRotation("../../ui/hunter/apls", "aoe"),
},

ItemFilter: ItemFilter,
Expand Down
26 changes: 7 additions & 19 deletions sim/mage/mage_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package mage

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common"
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterMage()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestArcane(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassMage,
Expand All @@ -34,9 +22,9 @@ func TestArcane(t *testing.T) {
Glyphs: ArcaneGlyphs,
Consumes: FullArcaneConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Arcane", SpecOptions: PlayerOptionsArcane},
Rotation: GetAplRotation("../../ui/mage/apls", "arcane"),
Rotation: core.GetAplRotation("../../ui/mage/apls", "arcane"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../ui/mage/apls", "arcane_aoe"),
core.GetAplRotation("../../ui/mage/apls", "arcane_aoe"),
},

ItemFilter: ItemFilter,
Expand All @@ -53,9 +41,9 @@ func TestFire(t *testing.T) {
Glyphs: FireGlyphs,
Consumes: FullFireConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Fire", SpecOptions: PlayerOptionsFire},
Rotation: GetAplRotation("../../ui/mage/apls", "fire"),
Rotation: core.GetAplRotation("../../ui/mage/apls", "fire"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../ui/mage/apls", "fire_aoe"),
core.GetAplRotation("../../ui/mage/apls", "fire_aoe"),
},

ItemFilter: ItemFilter,
Expand All @@ -72,7 +60,7 @@ func TestFrostFire(t *testing.T) {
Glyphs: FrostFireGlyphs,
Consumes: FullFireConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Fire", SpecOptions: PlayerOptionsFire},
Rotation: GetAplRotation("../../ui/mage/apls", "frostfire"),
Rotation: core.GetAplRotation("../../ui/mage/apls", "frostfire"),

ItemFilter: ItemFilter,
}))
Expand All @@ -88,9 +76,9 @@ func TestFrost(t *testing.T) {
Glyphs: FrostGlyphs,
Consumes: FullFrostConsumes,
SpecOptions: core.SpecOptionsCombo{Label: "Frost", SpecOptions: PlayerOptionsFrost},
Rotation: GetAplRotation("../../ui/mage/apls", "frost"),
Rotation: core.GetAplRotation("../../ui/mage/apls", "frost"),
OtherRotations: []core.RotationCombo{
GetAplRotation("../../ui/mage/apls", "frost_aoe"),
core.GetAplRotation("../../ui/mage/apls", "frost_aoe"),
},

ItemFilter: ItemFilter,
Expand Down
14 changes: 1 addition & 13 deletions sim/paladin/protection/protection_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package protection

import (
"log"
"os"
"testing"

_ "github.com/wowsims/wotlk/sim/common" // imported to get item effects included.
Expand All @@ -14,16 +12,6 @@ func init() {
RegisterProtectionPaladin()
}

func GetAplRotation(dir string, file string) core.RotationCombo {
filePath := dir + "/" + file + ".apl.json"
data, err := os.ReadFile(filePath)
if err != nil {
log.Fatalf("failed to load apl json file: %s, %s", filePath, err)
}

return core.RotationCombo{Label: file, Rotation: core.APLRotationFromJsonString(string(data))}
}

func TestProtection(t *testing.T) {
core.RunTestSuite(t, t.Name(), core.FullCharacterTestSuiteGenerator(core.CharacterSuiteConfig{
Class: proto.Class_ClassPaladin,
Expand Down Expand Up @@ -63,7 +51,7 @@ func TestProtection(t *testing.T) {
},
},
},
Rotation: GetAplRotation("../../../ui/protection_paladin/apls", "default"),
Rotation: core.GetAplRotation("../../../ui/protection_paladin/apls", "default"),

IsTank: true,
InFrontOfTarget: true,
Expand Down
Loading

0 comments on commit b2b0d09

Please sign in to comment.