The component test step the instance in the database for id "id" should be: is not returning an error when the assertion fails:
|
func (c *DatasetComponent) theInstanceInTheDatabaseForIdShouldBe(id string, body *godog.DocString) error { |
|
var expected models.Instance |
|
|
|
if err := json.Unmarshal([]byte(body.Content), &expected); err != nil { |
|
return fmt.Errorf("failed to unmarshal body: %w", err) |
|
} |
|
|
|
collectionName := c.MongoClient.ActualCollectionName(config.InstanceCollection) |
|
var got models.Instance |
|
|
|
if err := c.MongoClient.Connection.Collection(collectionName).FindOne(context.Background(), bson.M{"_id": id}, &got); err != nil { |
|
return fmt.Errorf("failed to get instance from collection: %w", err) |
|
} |
|
|
|
assert.Equal(&c.ErrorFeature, expected, got) |
|
|
|
return nil |
|
} |
And therefore the component tests using this step are wrongly passing.
The function should return c.ErrorFeature.StepError() so that the test fails when there are discrepancies in the expected value.
However, the component tests will need to be reviewed and rewritten as they won't pass as they are.
Also, they seem to be calling an endpoint that does not even exist:
|
When I PUT "/instances" |
|
""" |
|
{ |
|
"id": "test-item-4", |
|
"dimensions":[ |
|
{ |
|
"name": "foo", |
|
"is_area_type": false, |
|
} |
|
] |
|
} |
|
""" |
|
When I PUT "/instances" |
|
""" |
|
{ |
|
"id": "test-item-5", |
|
"dimensions":[ |
|
{ |
|
"name": "bar", |
|
"quality_statement_text": "This is a quality statement", |
|
"quality_statement_url": "www.ons.gov.uk/qualitystatement" |
|
} |
|
] |
|
} |
|
""" |
Presumably they should be calling PUT "/instances/{instance_id}"
A review of these tests is required
The component test step
the instance in the database for id "id" should be:is not returning an error when the assertion fails:dp-dataset-api/features/steps/steps.go
Lines 84 to 101 in 4a8072c
And therefore the component tests using this step are wrongly passing.
The function should return
c.ErrorFeature.StepError()so that the test fails when there are discrepancies in the expected value.However, the component tests will need to be reviewed and rewritten as they won't pass as they are.
Also, they seem to be calling an endpoint that does not even exist:
dp-dataset-api/features/instances.feature
Lines 342 to 353 in 4a8072c
dp-dataset-api/features/instances.feature
Lines 378 to 390 in 4a8072c
Presumably they should be calling
PUT "/instances/{instance_id}"A review of these tests is required