Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .ci/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ product="elastic/elasticsearch-serverless-js"
output_folder=".buildkite/output"
codegen_folder=".buildkite/output"
OUTPUT_DIR="$repo/${output_folder}"
NODE_VERSION=18
NODE_VERSION=22
WORKFLOW=${WORKFLOW-staging}
mkdir -p "$OUTPUT_DIR"

Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,33 @@ jobs:
- name: License checker
run: |
npm run license-checker
test-bun:
name: Test Bun
runs-on: ${{ matrix.os }}
needs: paths-filter
# only run if code relevant to unit tests was changed
if: needs.paths-filter.outputs.src-only == 'true'

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v4

- name: Use Bun
uses: oven-sh/setup-bun@v2

- name: Install
run: |
bun install
- name: Lint
run: |
bun run lint
- name: Unit test
run: |
bun run test:unit-bun
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ lib
yaml-rest-tests
cloud.json
junit-output
bun.lockb
rest-api-spec
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ CODE_OF_CONDUCT.md
CONTRIBUTING.md

src
bun.lockb
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test:coverage-report": "npm run build && tap test/unit/{*,**/*}.test.ts --coverage && nyc report --reporter=text-lcov > coverage.lcov",
"test:coverage-ui": "npm run build && tap test/unit/{*,**/*}.test.ts --coverage --coverage-report=html",
"test:integration": "npm run build && node ./test/integration/index.js",
"test:unit": "npm run build && tap test/unit/{*,**/*}.test.ts"
"test:unit": "npm run build && tap test/unit/{*,**/*}.test.ts",
"test:unit-bun": "bun run build && bunx tap"
},
"keywords": [
"elasticsearch",
Expand Down Expand Up @@ -85,6 +86,7 @@
"jsx": false,
"flow": false,
"coverage": false,
"check-coverage": false
"check-coverage": false,
"files": "test/unit/{*,**/*}.test.ts"
}
}
2 changes: 1 addition & 1 deletion test/unit/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ test('With generic document', async t => {
}

const Connection = connection.buildMockConnection({
onRequest (opts) {
onRequest (_opts) {
return {
statusCode: 200,
body: {
Expand Down
36 changes: 18 additions & 18 deletions test/unit/helpers/msearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import FakeTimers from '@sinonjs/fake-timers'

test('Basic', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -78,7 +78,7 @@ test('Multiple searches (inside async iterator)', t => {
t.plan(4)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -161,7 +161,7 @@ test('Multiple searches (async iterator exits)', t => {
t.plan(4)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -242,7 +242,7 @@ test('Multiple searches (async iterator exits)', t => {

test('Stop a msearch processor (promises)', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
Expand Down Expand Up @@ -272,7 +272,7 @@ test('Bad header', t => {
t.plan(1)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
Expand All @@ -297,7 +297,7 @@ test('Bad body', t => {
t.plan(1)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
Expand All @@ -321,7 +321,7 @@ test('Bad body', t => {
test('Retry on 429', async t => {
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
if (count++ === 0) {
return {
body: {
Expand Down Expand Up @@ -384,7 +384,7 @@ test('Retry on 429', async t => {

test('Single search errors', async t => {
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -419,7 +419,7 @@ test('Entire msearch fails', t => {
t.plan(2)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
statusCode: 500,
body: {
Expand Down Expand Up @@ -454,7 +454,7 @@ test('Resolves the msearch helper', t => {
t.plan(1)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
Expand All @@ -470,17 +470,17 @@ test('Resolves the msearch helper', t => {

m.then(
() => t.pass('called'),
e => t.fail('Should not fail')
_e => t.fail('Should not fail')
)

m.catch(e => t.fail('Should not fail'))
m.catch(_e => t.fail('Should not fail'))
})

test('Stop the msearch helper with an error', t => {
t.plan(3)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return { body: {} }
}
})
Expand Down Expand Up @@ -511,7 +511,7 @@ test('Multiple searches (concurrency = 1)', t => {
t.plan(4)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -587,7 +587,7 @@ test('Flush interval', t => {
t.teardown(() => clock.uninstall())

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -640,7 +640,7 @@ test('Flush interval - early stop', t => {
t.plan(2)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: [{
Expand Down Expand Up @@ -684,7 +684,7 @@ test('Stop should resolve the helper', t => {
t.plan(1)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: []
Expand All @@ -709,7 +709,7 @@ test('Stop should resolve the helper (error)', t => {
t.plan(3)

const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
return {
body: {
responses: []
Expand Down
10 changes: 4 additions & 6 deletions test/unit/helpers/scroll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ test('Scroll search (retry throws and maxRetries)', async t => {
const expectedAttempts = maxRetries + 1
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
count += 1
return { body: {}, statusCode: 429 }
}
Expand All @@ -220,8 +220,7 @@ test('Scroll search (retry throws and maxRetries)', async t => {
})

try {
// @ts-expect-error
for await (const result of scrollSearch) { // eslint-disable-line
for await (const _result of scrollSearch) { // eslint-disable-line
t.fail('we should not be here')
}
} catch (err: any) {
Expand Down Expand Up @@ -349,7 +348,7 @@ test('Should not retry if maxRetries = 0', async t => {
const expectedAttempts = 1
let count = 0
const MockConnection = connection.buildMockConnection({
onRequest (params) {
onRequest (_params) {
count += 1
return { body: {}, statusCode: 429 }
}
Expand All @@ -370,8 +369,7 @@ test('Should not retry if maxRetries = 0', async t => {
})

try {
// @ts-expect-error
for await (const result of scrollSearch) { // eslint-disable-line
for await (const _result of scrollSearch) { // eslint-disable-line
t.fail('we should not be here')
}
} catch (err: any) {
Expand Down