Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add tests for less common entity routes#920

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
olirice wants to merge2 commits intomaster
base:master
Choose a base branch
Loading
fromor/entity-route-test-coverage

Conversation

olirice
Copy link

@oliriceolirice commentedApr 2, 2025
edited
Loading

What kind of change does this PR introduce?

WARNING! LLM Generated, please review carefully

Test coverage for
server/config
server/extensions
server/format
server/functions
server/generators
server/policies
server/publications
server/triggers
server/types

to get coverage > 80%

@oliriceolirice requested review froma team ascode ownersApril 2, 2025 12:03
@coveralls
Copy link

coveralls commentedApr 2, 2025
edited
Loading

Pull Request Test Coverage Report forBuild 14224011078

Details

  • 3 of3(100.0%) changed or added relevant lines in1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.0%) to80.894%

TotalsCoverage Status
Change from baseBuild 14195985967:5.0%
Covered Lines:5331
Relevant Lines:6481

💛 -Coveralls

Comment on lines +115 to +117
if (!table || !name) {
return { data: null, error: { message: 'Missing required name or table parameter' } }
}
Copy link
Member

Choose a reason for hiding this comment

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

chore

Avoidident to raise an exception ending with500 if those params are empty. TODO: migrate all this to zod for better validation of the params.

import { expect, test } from 'vitest'
import { app } from './utils'

test('extension list filtering', async () => {

Choose a reason for hiding this comment

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

should we actually check that some extensions correctly returned?

it's also not filtering, name a bit misleading

`)
})

// TODO(andrew): Those should return 400 error code for invalid parameter

Choose a reason for hiding this comment

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

maybe 200 and do nothing?
empty string isnt smth bad really

Copy link
Member

Choose a reason for hiding this comment

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

Yeah agreed 200 is fine here. I think just like formatters in code editors it shouldn't fail when there are syntax errors; rather it should try to format the rest of the code despite the errors.

expect(res.statusCode).toBe(500)
})

test('format with missing query parameter', async () => {

Choose a reason for hiding this comment

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

todo:
this one should be 400 probably

soedirgo reacted with thumbs up emoji
import { expect, test } from 'vitest'
import { app } from './utils'

test('function list filtering', async () => {

Choose a reason for hiding this comment

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

Suggested change
test('function listfiltering',async()=>{
test('function listwith limit',async()=>{

Choose a reason for hiding this comment

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

i think it should create functions first and check that they are correctly returned, if we test with limit, probably we should also create limit + 1 first and then check that limit actually works

Copy link
Member

Choose a reason for hiding this comment

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

Yeah issue we currently have with this repo tests is that any changes to the schemas make side effect to all the other tests.

We'll need to setup something like this first:https://github.com/supabase/supabase/blob/master/packages/pg-meta/test/db/utils.ts

So each test can run in it's isolated database.

Choose a reason for hiding this comment

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

yeah, that is not great, but it is not the only way, another one is “create functions - test - drop functions”

Copy link
Member

@avalleteavalleteApr 9, 2025
edited
Loading

Choose a reason for hiding this comment

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

Issue with that is that still cause conflicts depending on the orders the tests run in / parallel runs (sometimes the drop didn't happen while another introspection query will get a different result). I guess we can make the tests more synchronous to avoid that, even if I'm not sure how, maybe wrap them indescribe ?

Choose a reason for hiding this comment

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

i mean, it prob wont conflict if you still check that there are exactly 5 functions and create 6 in advance, you dont have to check function names

for a better test we can also query functions from the database directly and check that pg-meta returns a subset of the functions that we got using db query directly

expect(Array.isArray(functions)).toBe(true)
// All functions should be in the public schema
functions.forEach((func) => {
expect(func.schema).toBe('public')

Choose a reason for hiding this comment

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

we should create some first in other schemas

})
})

test('trigger with invalid id', async () => {

Choose a reason for hiding this comment

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

Suggested change
test('trigger with invalid id',async()=>{
test('gettrigger with invalid id',async()=>{

expect(types.length).toBeLessThanOrEqual(5)
})

test('type list with specific included schema', async () => {

Choose a reason for hiding this comment

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

we need to create some in other schema(s) first

import { expect, test } from 'vitest'
import { app } from './utils'

test('type list filtering', async () => {

Choose a reason for hiding this comment

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

also same as for other list tests, we should create some first to check that they are returned and that limit works (not sure we have >5)

import { expect, test } from 'vitest'
import { app } from './utils'

test('type list filtering', async () => {

Choose a reason for hiding this comment

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

Suggested change
test('type listfiltering',async()=>{
test('type listwith limit',async()=>{

const types = res.json()
expect(Array.isArray(types)).toBe(true)
// Should not include array types
const arrayTypes = types.filter((type) => type.name.startsWith('_'))

Choose a reason for hiding this comment

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

do we have array types?
sorry if missed it

@oliriceolirice requested a review fromavalleteApril 3, 2025 15:03
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@soedirgosoedirgosoedirgo left review comments

@egor-romanovegor-romanovegor-romanov left review comments

@avalleteavalleteAwaiting requested review from avallete

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@olirice@coveralls@avallete@soedirgo@egor-romanov

[8]ページ先頭

©2009-2025 Movatter.jp