<commit_before>// @flow

import type {
  EntityClient
} from '../index.js'

const user1 = {
  id: 'user1',
  name: { first: 'Shin', last: 'Tanaka' },
  age: 10,
}

const user2 = {
  id: 'user2',
  name: { first: 'Shingo', last: 'Tanaka' },
  age: 16,
}

const user3 = {
  id: 'user3',
  name: { first: 'taro', last: 'Tanaka' },
  age: 19,
}

const user4 = {
  id: 'user4',
  name: { first: 'jiro', last: 'Tanaka' },
  age: 31,
}

const user5 = {
  id: 'user5',
  name: { first: 'saburo', last: 'Tanaka' },
  age: 26,
}

const user6 = {
  id: 'user6',
  name: { first: 'shiro', last: 'Tanaka' },
  age: 22,
}

const user7 = {
  id: 'user7',
  name: { first: 'goro', last: 'Tanaka' },
  age: 47,
}

let entityClient

export const assertEntityClient = (
  entityClientPromise: EntityClient | Promise<EntityClient>,
  kocha: any,
  assert: Function,
) => {
  const { describe, it, after, before } = kocha

  before(async () => {
    try {
      entityClient = await entityClientPromise
    }
    catch (e) {
      console.log(e.message) // eslint-disable-line no-console
    }
  })

  entityClient ? describe : describe.skip('assertEntityClient', () => {
    after(async () => {
      if (entityClient) {
        entityClient.delete({ entityName: 'user', where: {} })
      }
    })

    describe('insert', () => {
      it('inserts an entity with single insert command', async () => {<commit_msg>:hammer: Throw error as connection to mongodb failed<commit_after>// @flow

import type {
  EntityClient
} from '../index.js'

const user1 = {
  id: 'user1',
  name: { first: 'Shin', last: 'Tanaka' },
  age: 10,
}

const user2 = {
  id: 'user2',
  name: { first: 'Shingo', last: 'Tanaka' },
  age: 16,
}

const user3 = {
  id: 'user3',
  name: { first: 'taro', last: 'Tanaka' },
  age: 19,
}

const user4 = {
  id: 'user4',
  name: { first: 'jiro', last: 'Tanaka' },
  age: 31,
}

const user5 = {
  id: 'user5',
  name: { first: 'saburo', last: 'Tanaka' },
  age: 26,
}

const user6 = {
  id: 'user6',
  name: { first: 'shiro', last: 'Tanaka' },
  age: 22,
}

const user7 = {
  id: 'user7',
  name: { first: 'goro', last: 'Tanaka' },
  age: 47,
}

let entityClient

export const assertEntityClient = (
  entityClientPromise: EntityClient | Promise<EntityClient>,
  kocha: any,
  assert: Function,
) => {
  const { describe, it, after, before } = kocha

  before(async () => {
    entityClient = await entityClientPromise
  })

  describe('assertEntityClient', () => {
    after(async () => {
      entityClient.delete({ entityName: 'user', where: {} })
    })

    describe('insert', () => {
      it('inserts an entity with single insert command', async () => {
{'fraction_non_alphanumeric': 0.18305084745762712, 'fraction_numerical': 0.021092278719397364, 'mean_word_length': 3.04261796042618, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5554420', 'n_tokens_mistral': 1041, 'n_tokens_neox': 988, 'n_words': 259}