refactor: move testing data to custom package faker (interna/faker)
This commit is contained in:
parent
bd135bcfe6
commit
18d1c98b76
3 changed files with 262 additions and 169 deletions
|
|
@ -3,9 +3,6 @@ package training
|
|||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/internal/currency"
|
||||
)
|
||||
|
||||
type TrainingRepository interface {
|
||||
|
|
@ -22,174 +19,9 @@ type InMemoryTrainingRepository struct {
|
|||
}
|
||||
|
||||
func NewInMemoryTrainingRepository() *InMemoryTrainingRepository {
|
||||
repo := &InMemoryTrainingRepository{
|
||||
return &InMemoryTrainingRepository{
|
||||
trainings: make(map[TrainingID]Training),
|
||||
}
|
||||
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Kubernetes",
|
||||
Days: 2,
|
||||
Description: "Kubernetes",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(450),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(2000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(9900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(49000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Terraform",
|
||||
Days: 1,
|
||||
Description: "Terraform",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
_ = repo.Create(&Training{
|
||||
Name: "RKE2",
|
||||
Days: 1,
|
||||
Description: "RKE2",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
_ = repo.Create(&Training{
|
||||
Name: "GitHub Actions",
|
||||
Days: 1,
|
||||
Description: "GitHub Actions",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
_ = repo.Create(&Training{
|
||||
Name: "GitLab CI",
|
||||
Days: 1,
|
||||
Description: "GitLab CI",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Prometheus",
|
||||
Days: 2,
|
||||
Description: "Prometheus",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(450),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(2000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(9900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(49000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return repo
|
||||
}
|
||||
|
||||
func (r *InMemoryTrainingRepository) Create(training *Training) error {
|
||||
|
|
|
|||
Reference in a new issue