From 79632c409adf6b916aab89a34fa4e006a292f315 Mon Sep 17 00:00:00 2001 From: Vojtech Mares Date: Sun, 12 May 2024 23:34:25 +0200 Subject: [PATCH] test(server): add tests for updating, deleteing and listing trainings --- internal/server/server_test.go | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/internal/server/server_test.go b/internal/server/server_test.go index 2556d58..4642ace 100644 --- a/internal/server/server_test.go +++ b/internal/server/server_test.go @@ -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" @@ -87,27 +88,27 @@ func TestServer(t *testing.T) { Name: "Testing Training", 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, - //}, + Pricing: []TrainingPrice{ + { + 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) { @@ -177,12 +178,12 @@ func TestServer(t *testing.T) { Name: "Updated Training", Description: tr.Description, Days: tr.Days, - Pricing: []TrainingPrice{ - //{ - // Amount: decimal.NewFromInt(200), - // Currency: "EUR", - // Type: OPEN, - //}, + Pricing: []TrainingPrice{ + { + Amount: decimal.NewFromInt(200).String(), + Currency: money.EUR, + Type: OPEN, + }, }, }