feat!: add slug to training
BREAKING CHANGE: update init migration
This commit is contained in:
parent
556b4f4e79
commit
2d32c80182
12 changed files with 219 additions and 45 deletions
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/shopspring/decimal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/internal/money"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/pkg/slug"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/pkg/training"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
|
@ -115,6 +116,8 @@ func TestServer(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
slugString := slug.NewString(newTraining.Name)
|
||||
|
||||
rr, _ := doPost(t, app, "/v1/trainings", newTraining)
|
||||
assert.Equal(t, http.StatusCreated, rr.StatusCode)
|
||||
|
||||
|
|
@ -122,6 +125,7 @@ func TestServer(t *testing.T) {
|
|||
err := json.NewDecoder(rr.Body).Decode(&resultTraining)
|
||||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, newTraining.Name, resultTraining.Name)
|
||||
assert.Equal(t, slugString, resultTraining.Slug)
|
||||
assert.Equal(t, newTraining.Description, resultTraining.Description)
|
||||
assert.Equal(t, newTraining.Days, resultTraining.Days)
|
||||
assert.Equal(t, newTraining.Pricing, resultTraining.Pricing)
|
||||
|
|
@ -177,8 +181,10 @@ func TestServer(t *testing.T) {
|
|||
|
||||
_ = handlers.trainingRepository.Create(tr)
|
||||
|
||||
updatedSlug := "updated-training"
|
||||
updTr := NewTraining{
|
||||
Name: "Updated Training",
|
||||
Slug: &updatedSlug,
|
||||
Description: tr.Description,
|
||||
Days: tr.Days,
|
||||
Pricing: []TrainingPrice{
|
||||
|
|
@ -197,6 +203,7 @@ func TestServer(t *testing.T) {
|
|||
err := json.NewDecoder(rr.Body).Decode(&trr)
|
||||
assert.NoError(t, err, "error unmarshalling response")
|
||||
assert.Equal(t, updTr.Name, trr.Name)
|
||||
assert.Equal(t, updatedSlug, trr.Slug)
|
||||
})
|
||||
|
||||
t.Run("Delete training", func(t *testing.T) {
|
||||
|
|
|
|||
Reference in a new issue