1
0
Fork 0

test(server): add tests for updating, deleteing and listing trainings

This commit is contained in:
Vojtěch Mareš 2024-05-12 23:34:25 +02:00
parent 81c265252f
commit 79632c409a
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D

View file

@ -6,6 +6,7 @@ import (
"github.com/gofiber/fiber/v2"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
"gitlab.mareshq.com/hq/yggdrasil/internal/money"
"gitlab.mareshq.com/hq/yggdrasil/pkg/training"
"net/http"
"net/http/httptest"
@ -88,26 +89,26 @@ func TestServer(t *testing.T) {
Description: "This is a test training",
Days: 1,
Pricing: []TrainingPrice{
//{
// Amount: decimal.NewFromInt(200),
// Currency: "EUR",
// Type: OPEN,
//},
//{
// Amount: decimal.NewFromInt(1000),
// Currency: "EUR",
// Type: CORPORATE,
//},
//{
// Amount: decimal.NewFromInt(4900),
// Currency: "CZK",
// Type: OPEN,
//},
//{
// Amount: decimal.NewFromInt(24000),
// Currency: "CZK",
// Type: CORPORATE,
//},
{
Amount: "200",
Currency: "EUR",
Type: OPEN,
},
{
Amount: "1000",
Currency: "EUR",
Type: CORPORATE,
},
{
Amount: "4900",
Currency: "CZK",
Type: OPEN,
},
{
Amount: "24000",
Currency: "CZK",
Type: CORPORATE,
},
},
}
@ -120,7 +121,7 @@ func TestServer(t *testing.T) {
assert.Equal(t, newTraining.Name, resultTraining.Name)
assert.Equal(t, newTraining.Description, resultTraining.Description)
assert.Equal(t, newTraining.Days, resultTraining.Days)
//assert.Equal(t, newTraining.Pricing, resultTraining.Pricing)
assert.Equal(t, newTraining.Pricing, resultTraining.Pricing)
})
t.Run("Training not found", func(t *testing.T) {
@ -178,11 +179,11 @@ func TestServer(t *testing.T) {
Description: tr.Description,
Days: tr.Days,
Pricing: []TrainingPrice{
//{
// Amount: decimal.NewFromInt(200),
// Currency: "EUR",
// Type: OPEN,
//},
{
Amount: decimal.NewFromInt(200).String(),
Currency: money.EUR,
Type: OPEN,
},
},
}