Skip to content

Commit

Permalink
chore: (api) smaller sample size for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobPotter committed Nov 4, 2024
1 parent 56c9802 commit a58fdfc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/controllers/pokemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *PokmemonTestSuite) SetupTest() {
initJobs := os.Getenv("INIT_JOBS")

if initJobs == "true" {
jobs.RefreshDB{DB: models.DB}.Run()
jobs.RefreshDB{DB: models.DB, Test: true}.Run()
}

}
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *TypeTestSuite) SetupTest() {
initJobs := os.Getenv("INIT_JOBS")

if initJobs == "true" {
jobs.RefreshDB{DB: models.DB}.Run()
jobs.RefreshDB{DB: models.DB, Test: true}.Run()
}

}
Expand Down
14 changes: 12 additions & 2 deletions api/jobs/refresh-db.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
)

type RefreshDB struct {
DB *gorm.DB
DB *gorm.DB
Test bool
}

type DamageLink struct {
Expand Down Expand Up @@ -113,7 +114,16 @@ func (r RefreshDB) refreshTypes() {
}

func (r RefreshDB) refreshPokemon() {
pokemonResource, err := pokeapi.Resource("pokemon-species", 0, 1500)

var count int

if r.Test {
count = 50
} else {
count = 1500
}

pokemonResource, err := pokeapi.Resource("pokemon-species", 0, count)

if err != nil {
log.Printf("Failed to get pokemon: %s", err)
Expand Down

0 comments on commit a58fdfc

Please sign in to comment.