refactor: use serial as id instead of uuid
This commit is contained in:
parent
18b033add1
commit
370531a9a5
11 changed files with 319 additions and 381 deletions
|
|
@ -2356,24 +2356,24 @@ var swaggerSpec = []string{
|
|||
"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",
|
||||
}
|
||||
|
||||
// GetSwagger returns the content of the embedded swagger specification file
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package server
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/google/uuid"
|
||||
"github.com/oapi-codegen/runtime/types"
|
||||
"github.com/shopspring/decimal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
@ -128,7 +128,7 @@ func TestServer(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("Training not found", func(t *testing.T) {
|
||||
rr, _ := doGet(t, app, "/v1/trainings/97b0e954-14f3-4908-98fa-271f505056d3")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d", 9999999))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
|
||||
var trainingError NotFoundError
|
||||
|
|
@ -190,7 +190,7 @@ func TestServer(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
rr, _ := doPut(t, app, "/v1/trainings/"+tr.ID.String(), updTr)
|
||||
rr, _ := doPut(t, app, fmt.Sprintf("/v1/trainings/%d", tr.ID), updTr)
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var trr Training
|
||||
|
|
@ -215,7 +215,7 @@ func TestServer(t *testing.T) {
|
|||
|
||||
_ = handlers.trainingRepository.Create(tr)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d", tr.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var trr Training
|
||||
|
|
@ -223,10 +223,10 @@ func TestServer(t *testing.T) {
|
|||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, tr.ID, trr.Id)
|
||||
|
||||
drr, _ := doDelete(t, app, "/v1/trainings/"+tr.ID.String())
|
||||
drr, _ := doDelete(t, app, fmt.Sprintf("/v1/trainings/%d", tr.ID))
|
||||
assert.Equal(t, http.StatusNoContent, drr.StatusCode)
|
||||
|
||||
rr, _ = doGet(t, app, "/v1/trainings/"+tr.ID.String())
|
||||
rr, _ = doGet(t, app, fmt.Sprintf("/v1/trainings/%d", tr.ID))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
|
||||
var trainingError NotFoundError
|
||||
|
|
@ -271,7 +271,7 @@ func TestServer(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
rr, err := doPost(t, app, "/v1/trainings/"+tr.ID.String()+"/dates", newTrainingDate)
|
||||
rr, err := doPost(t, app, fmt.Sprintf("/v1/trainings/%d/dates", tr.ID), newTrainingDate)
|
||||
|
||||
assert.Equal(t, http.StatusCreated, rr.StatusCode)
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ func TestServer(t *testing.T) {
|
|||
|
||||
_ = handlers.trainingRepository.Create(tr)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/97b0e954-14f3-4908-98fa-271f505056d3")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d", tr.ID, 999999))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
|
||||
var trainingError NotFoundError
|
||||
|
|
@ -331,17 +331,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
|
||||
trainingCount := 5
|
||||
|
|
@ -350,7 +348,7 @@ func TestServer(t *testing.T) {
|
|||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
}
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates", tr.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var trainingDates []TrainingDate
|
||||
|
|
@ -377,17 +375,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
|
@ -406,7 +402,7 @@ func TestServer(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
rr, _ := doPut(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String(), updTd)
|
||||
rr, _ := doPut(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d", tr.ID, td.ID), updTd)
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var tdrr TrainingDate
|
||||
|
|
@ -440,22 +436,20 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d", tr.ID, td.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var tdrr TrainingDate
|
||||
|
|
@ -463,10 +457,10 @@ func TestServer(t *testing.T) {
|
|||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, td.ID, tdrr.Id)
|
||||
|
||||
drr, _ := doDelete(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String())
|
||||
drr, _ := doDelete(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d", tr.ID, td.ID))
|
||||
assert.Equal(t, http.StatusNoContent, drr.StatusCode)
|
||||
|
||||
rr, _ = doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String())
|
||||
rr, _ = doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d", tr.ID, td.ID))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
|
||||
var trainingError NotFoundError
|
||||
|
|
@ -474,7 +468,7 @@ func TestServer(t *testing.T) {
|
|||
assert.NoError(t, err, "error getting response", err)
|
||||
assert.Equal(t, http.StatusNotFound, trainingError.Status)
|
||||
|
||||
lrr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates")
|
||||
lrr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates", tr.ID))
|
||||
assert.Equal(t, http.StatusOK, lrr.StatusCode)
|
||||
|
||||
var trainingDates []TrainingDate
|
||||
|
|
@ -503,22 +497,20 @@ func TestServer(t *testing.T) {
|
|||
for i := -4; i <= 5; i++ {
|
||||
date := now.AddDate(0, 0, i)
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
}
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/upcoming-dates")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/upcoming-dates", tr.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var trainingDatesReturned []TrainingDate
|
||||
|
|
@ -577,47 +569,41 @@ func TestServer(t *testing.T) {
|
|||
for i := -4; i <= upcomingTrainingCount; i++ {
|
||||
date := now.AddDate(0, 0, i)
|
||||
td1 := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr1.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr1.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr1.ID, td1)
|
||||
|
||||
td2 := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr2.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr2.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr2.ID, td2)
|
||||
|
||||
td3 := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr3.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr3.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr3.ID, td3)
|
||||
}
|
||||
|
|
@ -656,21 +642,19 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+uuid.New().String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, 99999999))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
|
||||
var notFound NotFoundError
|
||||
|
|
@ -698,17 +682,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
|
|
@ -721,7 +703,7 @@ func TestServer(t *testing.T) {
|
|||
IsStudent: new(bool),
|
||||
}
|
||||
|
||||
rr, _ := doPost(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees", newTrainingDateAttendee)
|
||||
rr, _ := doPost(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees", tr.ID, td.ID), newTrainingDateAttendee)
|
||||
assert.Equal(t, http.StatusCreated, rr.StatusCode)
|
||||
|
||||
var attendeeResponse TrainingDateAttendee
|
||||
|
|
@ -733,8 +715,8 @@ func TestServer(t *testing.T) {
|
|||
assert.Equal(t, newTrainingDateAttendee.Position, attendeeResponse.Position)
|
||||
assert.Equal(t, newTrainingDateAttendee.Phone, attendeeResponse.Phone)
|
||||
assert.Equal(t, newTrainingDateAttendee.IsStudent, attendeeResponse.IsStudent)
|
||||
assert.Equal(t, td.Price.Amount.String(), attendeeResponse.Bill.Amount)
|
||||
assert.Equal(t, td.Price.Currency, attendeeResponse.Bill.Currency)
|
||||
assert.Equal(t, td.PriceAmount.String(), attendeeResponse.Bill.Amount)
|
||||
assert.Equal(t, td.PriceCurrency, attendeeResponse.Bill.Currency)
|
||||
assert.Equal(t, false, attendeeResponse.HasPaid)
|
||||
assert.Equal(t, false, attendeeResponse.HasAttended)
|
||||
})
|
||||
|
|
@ -758,17 +740,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
|
|
@ -776,24 +756,22 @@ func TestServer(t *testing.T) {
|
|||
attendees := make([]training.TrainingDateAttendee, attendeeCount)
|
||||
for i := range attendeeCount {
|
||||
nAtd := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
}
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, nAtd)
|
||||
attendees[i] = *nAtd
|
||||
}
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees", tr.ID, td.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var attendeesResponse ListTrainingDateAttendeesResponse
|
||||
|
|
@ -809,8 +787,8 @@ func TestServer(t *testing.T) {
|
|||
assert.Equal(t, attendees[i].Position, attendee.Position)
|
||||
assert.Equal(t, attendees[i].IsStudent, *attendee.IsStudent)
|
||||
assert.Equal(t, attendees[i].Phone, attendee.Phone)
|
||||
assert.Equal(t, attendees[i].Bill.Amount.String(), attendee.Bill.Amount)
|
||||
assert.Equal(t, attendees[i].Bill.Currency, attendee.Bill.Currency)
|
||||
assert.Equal(t, attendees[i].BillAmount.String(), attendee.Bill.Amount)
|
||||
assert.Equal(t, attendees[i].BillCurrency, attendee.Bill.Currency)
|
||||
assert.Equal(t, attendees[i].HasPaid, attendee.HasPaid)
|
||||
assert.Equal(t, attendees[i].HasAttended, attendee.HasAttended)
|
||||
}
|
||||
|
|
@ -835,38 +813,34 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
attendee := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, attendee)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
|
||||
var resultTrainingDateAttendee TrainingDateAttendee
|
||||
err := json.NewDecoder(rr.Body).Decode(&resultTrainingDateAttendee)
|
||||
|
|
@ -877,8 +851,8 @@ func TestServer(t *testing.T) {
|
|||
assert.Equal(t, attendee.Position, resultTrainingDateAttendee.Position)
|
||||
assert.Equal(t, attendee.IsStudent, *resultTrainingDateAttendee.IsStudent)
|
||||
assert.Equal(t, attendee.Phone, resultTrainingDateAttendee.Phone)
|
||||
assert.Equal(t, attendee.Bill.Amount.String(), resultTrainingDateAttendee.Bill.Amount)
|
||||
assert.Equal(t, attendee.Bill.Currency, resultTrainingDateAttendee.Bill.Currency)
|
||||
assert.Equal(t, attendee.BillAmount.String(), resultTrainingDateAttendee.Bill.Amount)
|
||||
assert.Equal(t, attendee.BillCurrency, resultTrainingDateAttendee.Bill.Currency)
|
||||
assert.Equal(t, attendee.HasPaid, resultTrainingDateAttendee.HasPaid)
|
||||
assert.Equal(t, attendee.HasAttended, resultTrainingDateAttendee.HasAttended)
|
||||
})
|
||||
|
|
@ -902,33 +876,29 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
attendee := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, attendee)
|
||||
|
|
@ -942,7 +912,7 @@ func TestServer(t *testing.T) {
|
|||
IsStudent: new(bool),
|
||||
}
|
||||
|
||||
rr, _ := doPut(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String(), newTrainingDateAttendee)
|
||||
rr, _ := doPut(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID), newTrainingDateAttendee)
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var attendeeResponse UpdateTrainingDateAttendeeResponse
|
||||
|
|
@ -954,8 +924,8 @@ func TestServer(t *testing.T) {
|
|||
assert.Equal(t, newTrainingDateAttendee.Position, attendeeResponse.Position)
|
||||
assert.Equal(t, newTrainingDateAttendee.Phone, attendeeResponse.Phone)
|
||||
assert.Equal(t, newTrainingDateAttendee.IsStudent, attendeeResponse.IsStudent)
|
||||
assert.Equal(t, td.Price.Amount.String(), attendeeResponse.Bill.Amount)
|
||||
assert.Equal(t, td.Price.Currency, attendeeResponse.Bill.Currency)
|
||||
assert.Equal(t, td.PriceAmount.String(), attendeeResponse.Bill.Amount)
|
||||
assert.Equal(t, td.PriceCurrency, attendeeResponse.Bill.Currency)
|
||||
assert.Equal(t, attendee.HasPaid, attendeeResponse.HasPaid)
|
||||
assert.Equal(t, attendee.HasAttended, attendeeResponse.HasAttended)
|
||||
})
|
||||
|
|
@ -979,44 +949,40 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
attendee := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, attendee)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
rr, _ = doDelete(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ = doDelete(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusNoContent, rr.StatusCode)
|
||||
|
||||
rr, _ = doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ = doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusNotFound, rr.StatusCode)
|
||||
})
|
||||
|
||||
|
|
@ -1039,17 +1005,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
|
|
@ -1058,23 +1022,21 @@ func TestServer(t *testing.T) {
|
|||
}
|
||||
|
||||
attendee := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: !paid.Paid,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: !paid.Paid,
|
||||
HasAttended: false,
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, attendee)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var attendeeResponse TrainingDateAttendee
|
||||
|
|
@ -1082,14 +1044,14 @@ func TestServer(t *testing.T) {
|
|||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, !paid.Paid, attendeeResponse.HasPaid)
|
||||
|
||||
rr, _ = doPut(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String()+"/paid", paid)
|
||||
rr, _ = doPut(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d/paid", tr.ID, td.ID, attendee.ID), paid)
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
err = json.NewDecoder(rr.Body).Decode(&attendeeResponse)
|
||||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, paid.Paid, attendeeResponse.HasPaid)
|
||||
|
||||
rr, _ = doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ = doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
err = json.NewDecoder(rr.Body).Decode(&attendeeResponse)
|
||||
|
|
@ -1116,17 +1078,15 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
|
|
@ -1135,23 +1095,21 @@ func TestServer(t *testing.T) {
|
|||
}
|
||||
|
||||
attendee := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: !attended.Attended,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: !attended.Attended,
|
||||
}
|
||||
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, attendee)
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var attendeeResponse TrainingDateAttendee
|
||||
|
|
@ -1159,14 +1117,14 @@ func TestServer(t *testing.T) {
|
|||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, !attended.Attended, attendeeResponse.HasAttended)
|
||||
|
||||
rr, _ = doPut(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String()+"/attended", attended)
|
||||
rr, _ = doPut(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d/attended", tr.ID, td.ID, attendee.ID), attended)
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
err = json.NewDecoder(rr.Body).Decode(&attendeeResponse)
|
||||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, attended.Attended, attendeeResponse.HasAttended)
|
||||
|
||||
rr, _ = doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/"+attendee.ID.String())
|
||||
rr, _ = doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/%d", tr.ID, td.ID, attendee.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
err = json.NewDecoder(rr.Body).Decode(&attendeeResponse)
|
||||
|
|
@ -1193,40 +1151,36 @@ func TestServer(t *testing.T) {
|
|||
date := time.Date(2024, time.May, 1, 9, 0, 0, 0, time.UTC)
|
||||
|
||||
td := &training.TrainingDate{
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
Price: money.Money{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: "EUR",
|
||||
},
|
||||
Address: "Test Address 123, NYC",
|
||||
Capacity: 12,
|
||||
Date: date,
|
||||
Days: tr.Days,
|
||||
IsOnline: false,
|
||||
Location: "NYC",
|
||||
StartTime: date,
|
||||
PriceAmount: decimal.NewFromInt(200),
|
||||
PriceCurrency: "EUR",
|
||||
}
|
||||
_ = handlers.trainingDateRepository.Create(tr.ID, td)
|
||||
|
||||
attendeeCount := 9
|
||||
for range attendeeCount {
|
||||
nAtd := &training.TrainingDateAttendee{
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
Bill: money.Money{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
Name: "John Doe",
|
||||
Email: "john.doe@example.com",
|
||||
Company: "Acme Inc.",
|
||||
Position: "Software Engineer",
|
||||
Phone: "+420 123 456 789",
|
||||
IsStudent: false,
|
||||
BillAmount: td.PriceAmount,
|
||||
BillCurrency: td.PriceCurrency,
|
||||
HasPaid: false,
|
||||
HasAttended: false,
|
||||
}
|
||||
_ = handlers.trainingDateAttendeeRepository.Create(td.ID, nAtd)
|
||||
}
|
||||
|
||||
rr, _ := doGet(t, app, "/v1/trainings/"+tr.ID.String()+"/dates/"+td.ID.String()+"/attendees/count")
|
||||
rr, _ := doGet(t, app, fmt.Sprintf("/v1/trainings/%d/dates/%d/attendees/count", tr.ID, td.ID))
|
||||
assert.Equal(t, http.StatusOK, rr.StatusCode)
|
||||
|
||||
var attendeesResponse GetTrainingDateAttendeeCountResponse
|
||||
|
|
|
|||
Reference in a new issue