Skip to content

Commit bb86bd3

Browse files
authored
feat: add note field for MonthConfig (#653)
1 parent 9b2f4cd commit bb86bd3

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

api/docs.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,11 @@
37583758
"type": "string",
37593759
"example": "1969-06-01T00:00:00.000000Z"
37603760
},
3761+
"note": {
3762+
"description": "A note for the month config",
3763+
"type": "string",
3764+
"example": "Added 200€ here because we replaced Tim's expensive vase"
3765+
},
37613766
"overspendMode": {
37623767
"default": "AFFECT_AVAILABLE",
37633768
"allOf": [
@@ -3777,6 +3782,11 @@
37773782
"models.MonthConfigCreate": {
37783783
"type": "object",
37793784
"properties": {
3785+
"note": {
3786+
"description": "A note for the month config",
3787+
"type": "string",
3788+
"example": "Added 200€ here because we replaced Tim's expensive vase"
3789+
},
37803790
"overspendMode": {
37813791
"default": "AFFECT_AVAILABLE",
37823792
"allOf": [

api/swagger.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,10 @@ definitions:
740740
description: This is always set to 00:00 UTC on the first of the month.
741741
example: "1969-06-01T00:00:00.000000Z"
742742
type: string
743+
note:
744+
description: A note for the month config
745+
example: Added 200€ here because we replaced Tim's expensive vase
746+
type: string
743747
overspendMode:
744748
allOf:
745749
- $ref: '#/definitions/models.OverspendMode'
@@ -752,6 +756,10 @@ definitions:
752756
type: object
753757
models.MonthConfigCreate:
754758
properties:
759+
note:
760+
description: A note for the month config
761+
example: Added 200€ here because we replaced Tim's expensive vase
762+
type: string
755763
overspendMode:
756764
allOf:
757765
- $ref: '#/definitions/models.OverspendMode'

pkg/controllers/month_config_test.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,27 @@ func (suite *TestSuiteStandard) TestMonthConfigsCreate() {
5050
someMonth := types.NewMonth(2020, 3)
5151

5252
tests := []struct {
53-
name string
54-
envelopeID uuid.UUID
55-
month types.Month
56-
status int
53+
name string
54+
envelopeID uuid.UUID
55+
month types.Month
56+
note string
57+
overspendMode models.OverspendMode
58+
status int
5759
}{
58-
{"Standard create", envelope.Data.ID, someMonth, http.StatusCreated},
59-
{"duplicate config for same envelope and month", envelope.Data.ID, someMonth, http.StatusBadRequest},
60-
{"No envelope", uuid.New(), someMonth, http.StatusNotFound},
60+
{"Standard create", envelope.Data.ID, someMonth, "test note", models.AffectAvailable, http.StatusCreated},
61+
{"duplicate config for same envelope and month", envelope.Data.ID, someMonth, "", models.AffectAvailable, http.StatusBadRequest},
62+
{"No envelope", uuid.New(), someMonth, "", models.AffectAvailable, http.StatusNotFound},
6163
}
6264

6365
for _, tt := range tests {
6466
suite.T().Run(tt.name, func(t *testing.T) {
65-
_ = suite.createTestMonthConfig(tt.envelopeID, tt.month, models.MonthConfigCreate{}, tt.status)
67+
response := suite.createTestMonthConfig(tt.envelopeID, tt.month, models.MonthConfigCreate{Note: tt.note, OverspendMode: tt.overspendMode}, tt.status)
68+
69+
// Verify that fields are set correctly
70+
if tt.status == http.StatusCreated {
71+
assert.Equal(t, tt.overspendMode, response.Data.OverspendMode)
72+
assert.Equal(t, tt.note, response.Data.Note)
73+
}
6674
})
6775
}
6876
}

pkg/models/month_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type MonthConfig struct {
3030

3131
type MonthConfigCreate struct {
3232
OverspendMode OverspendMode `json:"overspendMode" example:"AFFECT_ENVELOPE" default:"AFFECT_AVAILABLE"`
33+
Note string `json:"note" example:"Added 200€ here because we replaced Tim's expensive vase" default:""` // A note for the month config
3334
}
3435

3536
// AfterSave also sets the links so that we do not need to

0 commit comments

Comments
 (0)