Giter Club home page Giter Club logo

Comments (7)

fetinin avatar fetinin commented on May 24, 2024 1

I also think that this functionality will be useful and improve tests readability.

Now we use the following workaround with cases:

  dbQuery: >
    {{ .query }}
  cases:
    - dbQueryArgs:
        query: SELECT 1
      dbResponse: 1
    - dbQueryArgs:
        query: SELECT 2
      dbResponse: 2

But that is verbose, non-intuitive and executes test again for each query.

from gonkey.

leorush avatar leorush commented on May 24, 2024

Why don't you use subqueries?

from gonkey.

svzhl avatar svzhl commented on May 24, 2024
SELECT
(
  SELECT id, name
  FROM items
),
(
  SELECT value
  FROM properties
)

would result in pq: subquery must return only one column as the first subquery selects two columns.

from gonkey.

leorush avatar leorush commented on May 24, 2024

Depends on data you trying to check. Usually i use COUNT funсtion in subqueries, to check that there are given number of records in some table. For ex:

(SELECT COUNT(*) AS value_count FROM properties WHERE value = 'my_value' AND item_id = id )

If you want to transpose rows to columns, check this out https://stackoverflow.com/questions/23060256/postgres-transpose-rows-to-columns

from gonkey.

svzhl avatar svzhl commented on May 24, 2024

Checking only count is quite a limiting functionality.

Thanks for pointing out crosstab function, it is indeed useful in some cases. But it adds a little bit of complication to both writing and reading tests. Besides it doesn't solve an issue of querying 2 and more independent tables. Using joins and crosstab() function may mislead readers about intentions of the author.

from gonkey.

keyclaim avatar keyclaim commented on May 24, 2024

I think we need change rule:
Test must contains request + response
to
Test must contains request + response OR dbQuery + dbResponse

from gonkey.

github-actions avatar github-actions commented on May 24, 2024

🚀 Issue was released in v1.18.0 🚀

from gonkey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.