Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review component test for PUT instances #414

Open
rafahop opened this issue Mar 20, 2023 · 0 comments
Open

Review component test for PUT instances #414

rafahop opened this issue Mar 20, 2023 · 0 comments

Comments

@rafahop
Copy link
Contributor

rafahop commented Mar 20, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant