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