update:
sepated logic to hit invalid source,resource id during test case.
This commit is contained in:
parent
f4a776d175
commit
ca450f5793
|
@ -127,23 +127,31 @@ func (suite *ResourcFhirHandlerTestSuite) TestGetResourceFhirHandler() {
|
||||||
require.Equal(suite.T(),suite.SourceId, respWrapper.Data.SourceID)
|
require.Equal(suite.T(),suite.SourceId, respWrapper.Data.SourceID)
|
||||||
require.Equal(suite.T(),"57959813-8cd2-4e3c-8970-e4364b74980a", respWrapper.Data.SourceResourceID)
|
require.Equal(suite.T(),"57959813-8cd2-4e3c-8970-e4364b74980a", respWrapper.Data.SourceResourceID)
|
||||||
|
|
||||||
// passing invalid sourceId & responseId
|
}
|
||||||
w.Body.Reset()
|
|
||||||
ctx.Params = []gin.Param {
|
func (suite *ResourcFhirHandlerTestSuite) TestGetResourceFhirHandler_WithInvalidSourceResourceId() {
|
||||||
{
|
w := httptest.NewRecorder()
|
||||||
Key: "sourceId",
|
ctx, _ := gin.CreateTestContext(w)
|
||||||
Value: "57959813-9999-4e3c-8970-e4364b74980a",
|
ctx.Set(pkg.ContextKeyTypeLogger, logrus.WithField("test", suite.T().Name()))
|
||||||
},
|
ctx.Set(pkg.ContextKeyTypeDatabase, suite.AppRepository)
|
||||||
{
|
ctx.Set(pkg.ContextKeyTypeConfig, suite.AppConfig)
|
||||||
Key: "resourceId",
|
ctx.Set(pkg.ContextKeyTypeEventBusServer, suite.AppEventBus)
|
||||||
Value: "57959813-9999-4e3c-8970-e4364b74980a",
|
ctx.Set(pkg.ContextKeyTypeAuthUsername, "test_user")
|
||||||
},
|
|
||||||
}
|
ctx.AddParam("sourceId", "-1")
|
||||||
|
ctx.AddParam("resourceId", "57959813-9999-4e3c-8970-e4364b74980a")
|
||||||
|
|
||||||
GetResourceFhir(ctx)
|
GetResourceFhir(ctx)
|
||||||
|
|
||||||
err = json.Unmarshal(w.Body.Bytes(), &respWrapper)
|
type ResponseWrapper struct {
|
||||||
|
Data *models.ResourceBase `json:"data"`
|
||||||
|
Success bool `json:"success"`
|
||||||
|
}
|
||||||
|
var respWrapper ResponseWrapper
|
||||||
|
err := json.Unmarshal(w.Body.Bytes(), &respWrapper)
|
||||||
require.NoError(suite.T(),err)
|
require.NoError(suite.T(),err)
|
||||||
|
|
||||||
require.Equal(suite.T(),false,respWrapper.Success)
|
require.Equal(suite.T(),false,respWrapper.Success)
|
||||||
}
|
require.Nil(suite.T(),respWrapper.Data)
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue