Skip to content

Commit 7177243

Browse files
authored
fix: add envelope link, fix zero padding for self link for MonthConfigs (#443)
1 parent 00ca412 commit 7177243

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pkg/controllers/month_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ func (co Controller) getMonthConfigObject(c *gin.Context, mConfig models.MonthCo
339339
return MonthConfig{
340340
mConfig,
341341
MonthConfigLinks{
342-
Self: fmt.Sprintf("%s/v1/month-configs/%s/%d-%d", c.GetString("baseURL"), mConfig.EnvelopeID, mConfig.Month.Year(), mConfig.Month.Month()),
342+
Self: fmt.Sprintf("%s/v1/month-configs/%s/%04d-%02d", c.GetString("baseURL"), mConfig.EnvelopeID, mConfig.Month.Year(), mConfig.Month.Month()),
343+
Envelope: fmt.Sprintf("%s/v1/envelopes/%s", c.GetString("baseURL"), mConfig.EnvelopeID),
343344
},
344345
}
345346
}

pkg/controllers/month_config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ func (suite *TestSuiteStandard) TestMonthConfigsGet() {
117117

118118
recorder := test.Request(suite.controller, suite.T(), http.MethodGet, path, "")
119119
assert.Equal(t, tt.status, recorder.Code, "Request ID %s", recorder.Header().Get("x-request-id"))
120+
121+
if tt.status == http.StatusOK {
122+
var mConfig controllers.MonthConfigResponse
123+
suite.decodeResponse(&recorder, &mConfig)
124+
125+
selfLink := fmt.Sprintf("http://example.com/v1/month-configs/%s/%s", tt.envelopeID, tt.month)
126+
assert.Equal(t, selfLink, mConfig.Data.Links.Self, "Request ID %s", recorder.Header().Get("x-request-id"))
127+
128+
envelopeLink := fmt.Sprintf("http://example.com/v1/envelopes/%s", tt.envelopeID)
129+
assert.Equal(t, envelopeLink, mConfig.Data.Links.Envelope, "Request ID %s", recorder.Header().Get("x-request-id"))
130+
}
120131
})
121132
}
122133
}

0 commit comments

Comments
 (0)