Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 committed May 2, 2024
1 parent 2a8b6b0 commit dd9b63b
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions tailcall-cloudflare/tests/cf_tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@ import {readFile} from "fs/promises"
import {mf} from "./mf"

describe("fetch", () => {
test("loadfiles", async () => {
let placeholder = (await readFile("../examples/jsonplaceholder.graphql")).toString()
let placeholder_batch = (await readFile("../examples/jsonplaceholder_batch.graphql")).toString()
let grpc = (await readFile("../examples/grpc.graphql")).toString()
let news_proto = (await readFile("../tailcall-fixtures/fixtures/protobuf/news.proto")).toString()
test("loadfiles", async () => {
let placeholder = (await readFile("../examples/jsonplaceholder.graphql")).toString()
let placeholder_batch = (await readFile("../examples/jsonplaceholder_batch.graphql")).toString()
let grpc = (await readFile("../examples/grpc.graphql")).toString()
let news_proto = (await readFile("../tailcall-fixtures/fixtures/protobuf/news.proto")).toString()

let bucket = await mf.getR2Bucket("MY_R2")
await bucket.put("examples/grpc.graphql", grpc)
await bucket.put("examples/../tailcall-fixtures/fixtures/protobuf/news.proto", news_proto)
await bucket.put("tailcall-fixtures/fixtures/protobuf/news.proto", grpc)
await bucket.put("examples/jsonplaceholder.graphql", placeholder)
await bucket.put("examples/jsonplaceholder_batch.graphql", placeholder_batch)
})
let bucket = await mf.getR2Bucket("MY_R2")
await bucket.put("examples/grpc.graphql", grpc)
await bucket.put("examples/../tailcall-fixtures/fixtures/protobuf/news.proto", news_proto)
await bucket.put("tailcall-fixtures/fixtures/protobuf/news.proto", grpc)
await bucket.put("examples/jsonplaceholder.graphql", placeholder)
await bucket.put("examples/jsonplaceholder_batch.graphql", placeholder_batch)
})

test("sample_resp", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder.graphql", {
method: "POST",
body: '{"query":"{user(id: 1) {id}}"}',
})
let body = await resp.json()
let expected = {data: {user: {id: 1}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
test("sample_resp", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder.graphql", {
method: "POST",
body: '{"query":"{user(id: 1) {id}}"}',
})
let body = await resp.json()
let expected = {data: {user: {id: 1}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})

test("test_batching", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder_batch.graphql", {
method: "POST",
body: '{"query":"{ posts { id } }"}',
})
let body = await resp.json()
let expected = {data: {posts: [{id: 1}]}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
test("test_batching", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/jsonplaceholder_batch.graphql", {
method: "POST",
body: '{"query":"{ posts { id } }"}',
})
let body = await resp.json()
let expected = {data: {posts: [{id: 1}]}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})

test("test_grpc", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/grpc.graphql", {
method: "POST",
body: '{"query":"{ news { news { id } } }"}',
})
let body = await resp.json()
let expected = {data: {news: {news: [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}]}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
test("test_grpc", async () => {
let resp = await mf.dispatchFetch("https://fake.host/graphql?config=examples/grpc.graphql", {
method: "POST",
body: '{"query":"{ news { news { id } } }"}',
})
let body = await resp.json()
let expected = {data: {news: {news: [{id: 1}, {id: 2}, {id: 3}, {id: 4}, {id: 5}]}}}
expect(body).toEqual(expected)
expect(resp.status).toBe(200)
})
})

1 comment on commit dd9b63b

@github-actions
Copy link

Choose a reason for hiding this comment

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

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 7.58ms 3.63ms 123.06ms 73.90%
Req/Sec 3.35k 387.86 13.22k 87.59%

400349 requests in 30.10s, 2.01GB read

Requests/sec: 13300.61

Transfer/sec: 68.27MB

Please sign in to comment.