actually fix tests through mocks.

Этот коммит содержится в:
Conor Macpherson
2023-04-13 09:34:48 -04:00
родитель 0b731f4330
Коммит 7cc866ed89
2 изменённых файлов: 27 добавлений и 9 удалений

Просмотреть файл

@@ -8803,3 +8803,17 @@ func (c *Client4) GetWorkTemplatesByCategory(category string) ([]*WorkTemplate,
err = json.NewDecoder(r.Body).Decode(&templates)
return templates, BuildResponse(r), err
}
func (c *Client4) SubmitTrueUpReview(req map[string]any) (*Response, error) {
reqBytes, err := json.Marshal(req)
if err != nil {
return nil, NewAppError("SubmitTrueUpReview", "api.marshal_error", nil, "", http.StatusInternalServerError).Wrap(err)
}
r, err := c.DoAPIPostBytes(c.licenseRoute()+"/review", reqBytes)
if err != nil {
return BuildResponse(r), nil
}
defer closeBody(r)
return BuildResponse(r), nil
}

Просмотреть файл

@@ -484,7 +484,19 @@ func TestRequestTrueUpReview(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense())
t.Run("returns status 200 when telemetry data sent", func(t *testing.T) {
resp, err := th.SystemAdminClient.DoAPIPost("/license/review", "")
th.Client.Login(th.SystemAdminUser.Email, th.SystemAdminUser.Password)
cloud := mocks.CloudInterface{}
cloud.Mock.On("SubmitTrueUpReview", mock.Anything, mock.Anything).Return(nil)
cloudImpl := th.App.Srv().Cloud
defer func() {
th.App.Srv().Cloud = cloudImpl
}()
th.App.Srv().Cloud = &cloud
var reviewProfile map[string]any
resp, err := th.Client.SubmitTrueUpReview(reviewProfile)
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)
})
@@ -521,14 +533,6 @@ func TestTrueUpReviewStatus(t *testing.T) {
th.App.Srv().SetLicense(model.NewTestLicense())
t.Run("returns 200 when status retrieved", func(t *testing.T) {
cloud := mocks.CloudInterface{}
cloudImpl := th.App.Srv().Cloud
defer func() {
th.App.Srv().Cloud = cloudImpl
}()
th.App.Srv().Cloud = &cloud
resp, err := th.SystemAdminClient.DoAPIGet("/license/review/status", "")
require.NoError(t, err)
require.Equal(t, http.StatusOK, resp.StatusCode)