Skip to content

Add tests for getFieldUsageTrack query #9

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions test/integration/4_schema_usage_graphql_queries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Feature: As a customer
Then the response contains no errors
And the response contains JSON from file "getOperationUsageTrackLastHour.json"

Scenario: I request the usage of an operation with no usage record
Scenario: I request the usage of an operation with no usage record in the last month
Given the database is imported from 'schema_usage'
When I execute the graphQL query in file "getOperationUsageTrack.graphql" with variables:
"""
Expand All @@ -63,7 +63,7 @@ Feature: As a customer
| s_66_h45h2_1653653100 | 100 |
And the redis has the key 'o_12_h45h1' with value as in file 'o_12_h45h1-content.json'
And the redis has the key 'o_66_h45h2' with value as in file 'o_66_h45h2-content.json'
When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables:
When I execute the graphQL query in file "getEntityUsageTrack.graphql" with variables:
"""
{
"id": 99,
Expand All @@ -72,14 +72,47 @@ Feature: As a customer
}
"""
Then the response contains no errors
And the response contains JSON from file "getEntityUsageTrack.json"

Scenario: I request the usage of an object with no usage record in the last month
Given the database is imported from 'schema_usage'
When I execute the graphQL query in file "getEntityUsageTrack.graphql" with variables:
"""
{
"id": 99,
"startDate": "2022-05-01T00:00:00Z",
"endDate": "2022-05-31T23:59:59Z"
}
"""
Then the response contains no errors
And the response contains JSON from file "getEntityUsageTrackEmpty.json"

Scenario: I request the usage of a field in the last month
Given the database is imported from 'schema_usage'
And the redis contains the keys:
| e_12_h45h1_1653652800 | 100 |
| s_12_h45h1_1653652900 | 400 |
| e_66_h45h2_1653653000 | 50 |
| s_66_h45h2_1653653100 | 100 |
And the redis has the key 'o_12_h45h1' with value as in file 'o_12_h45h1-content.json'
And the redis has the key 'o_66_h45h2' with value as in file 'o_66_h45h2-content.json'
When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables:
"""
{
"id": 198,
"startDate": "2022-05-01T00:00:00Z",
"endDate": "2022-05-31T23:59:59Z"
}
"""
Then the response contains no errors
And the response contains JSON from file "getFieldUsageTrack.json"

Scenario: I request the usage of an object with no usage record
Scenario: I request the usage of a field with no usage record in the last month
Given the database is imported from 'schema_usage'
When I execute the graphQL query in file "getFieldUsageTrack.graphql" with variables:
"""
{
"id": 99,
"id": 198,
"startDate": "2022-05-01T00:00:00Z",
"endDate": "2022-05-31T23:59:59Z"
}
Expand Down
10 changes: 10 additions & 0 deletions test/integration/data/request/getEntityUsageTrack.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
query getEntityUsageTrack($id: Int!, $startDate: Date!, $endDate: Date!) {
getEntityUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) {
id
executions {
success
error
total
}
}
}
23 changes: 14 additions & 9 deletions test/integration/data/request/getFieldUsageTrack.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
query getFieldUsageTrack($id: Int!, $startDate: Date!, $endDate: Date!) {
getEntityUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) {
id
executions {
success
error
total
}
}
}
getFieldUsageTrack(id: $id, startDate: $startDate, endDate: $endDate) {
client {
name
versions {
id
execution {
success
error
total
}
}
}
}
}
22 changes: 22 additions & 0 deletions test/integration/data/response/getEntityUsageTrack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"data": {
"getEntityUsageTrack": [
{
"id": 198,
"executions": {
"success": 500,
"error": 150,
"total": 650
}
},
{
"id": 202,
"executions": {
"success": 400,
"error": 100,
"total": 500
}
}
]
}
}
5 changes: 5 additions & 0 deletions test/integration/data/response/getEntityUsageTrackEmpty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"data": {
"getEntityUsageTrack": []
}
}
35 changes: 21 additions & 14 deletions test/integration/data/response/getFieldUsageTrack.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"data": {
"getEntityUsageTrack": [
"getFieldUsageTrack": [
{
"id": 198,
"executions": {
"success": 500,
"error": 150,
"total": 650
}
},
{
"id": 202,
"executions": {
"success": 400,
"error": 100,
"total": 500
"client": {
"name": "local-test-microservice",
"versions": [
{
"id": "1.3.0",
"execution": {
"success": 100,
"error": 50,
"total": 150
}
},
{
"id": "1.2.3",
"execution": {
"success": 400,
"error": 100,
"total": 500
}
}
]
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"data": {
"getEntityUsageTrack": []
"getFieldUsageTrack": []
}
}
1 change: 0 additions & 1 deletion test/integration/steps/redis.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { readFileSync } from 'fs';
import { resolve } from 'path';
import { redisDataPath } from '../config/config';
import { getTimestamp } from '../../../src/redis/utils';
import { parseInputDate } from '../../../src/graphql/resolvers/getOperationUsageTrack';

let redisWrapper;

Expand Down