Skip to content

Conversation

@mads-hartmann
Copy link
Contributor

@mads-hartmann mads-hartmann commented Apr 30, 2021

While working on #3992 I was trying to add a few DB tests.

Before making changes to the code I wanted to create a basic test for the existing functionality, but unfortunately the test failed with a rather obscure error message

Cannot read property 'databaseName' of undefined

Turns out that TypeORM column names are case sensitive when used for ordering. In this case we used contextUrl and it should have been contextURL.

While column names in mysql are case insensitive I also fixed one other occurrence of contextUrl even though it is not necessary; but using the column names makes it easier to find when searching for references etc.

I also added a launch configuration for executing the db tests with the debugger enabled so you can step through them.

The test is currently failing with a missing database error. I think
this is a problem with the test database setup rather than the specific
test
@mads-hartmann mads-hartmann force-pushed the mads/workspace-db-test branch from edca096 to d9262c3 Compare May 27, 2021 13:32
@mads-hartmann
Copy link
Contributor Author

mads-hartmann commented May 27, 2021

/werft run

👍 started the job as gitpod-build-mads-workspace-db-test.3

Turns out that TypeORM column names are case sensitive when used for
ordering. The error message is terrible

    Cannot read property 'databaseName' of undefined

In this case we used contextUrl and it should have been contextURL.

While column names in mysql are case insensitive I also fixed one other
occurrence of contextUrl even though it is not necessary; but using the
column names makes it easier to find when searching for references etc.
@mads-hartmann mads-hartmann self-assigned this May 28, 2021
@mads-hartmann mads-hartmann requested a review from geropl May 28, 2021 09:45
@mads-hartmann mads-hartmann marked this pull request as ready for review May 28, 2021 09:47
Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, thx for digging in and fixing it.

In general we could think about using Object.keys to be sure we use the exact same field name. But that's Out of scope for this PR I think.

@mads-hartmann mads-hartmann merged commit b43fbfa into main May 28, 2021
@mads-hartmann mads-hartmann deleted the mads/workspace-db-test branch May 28, 2021 11:58
MatthewFagan pushed a commit to trilogy-group/gitpod that referenced this pull request Nov 22, 2021
* Add test for findAllWorkspaceAndInstances

The test is currently failing with a missing database error. I think
this is a problem with the test database setup rather than the specific
test

* Resolve failing test

Turns out that TypeORM column names are case sensitive when used for
ordering. The error message is terrible

    Cannot read property 'databaseName' of undefined

In this case we used contextUrl and it should have been contextURL.

While column names in mysql are case insensitive I also fixed one other
occurrence of contextUrl even though it is not necessary; but using the
column names makes it easier to find when searching for references etc.

* Add a launch configuration for db-test

* Add more assertions to the test
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

Successfully merging this pull request may close these issues.

Unable to add tests for findAllWorkspaceAndInstances

3 participants