<commit_before>const test = require('ava')
const Visit = require('./lib/visit')
const sleep = require('sleep-promise')
const url = require('url')

const {
  read,
  file
} = require('./lib/util')

test.cb('environment: should has no errors', t => {
  read(file('nohup.out'))
  .then((content) => {
    console.log(`nohup.out:\n${content}\n`)
    t.is(/error/i.test(content), false)
    t.end()
  })
})

const BACKEND_HOST = 'http://127.0.0.1:8080'
const SLEEP_TOLERANCE = 50

const CASES = [
  {
    d: 'simple request',
    u: '/',
    cache: true,
    expires: false
  },

  {
    d: 'expires',
    u: '/expires-1s',
    h: {
      'Gaia-Expires': '1000'
    },
    expires: 1000,
    cache: true
  },

  {
    d: 'if code is not 200, no cache',
    u: '/no-cache',
    cache: false,
    h: {
      code: 500
    }
  },

  {
    d: 'if http status is not 200, no cache',
    u: '/no-cache',
    cache: false,
    h: {
      status: 500
    }
  }
]

CASES.forEach(({d, u, cache, expires, only, h, method, b}) => {
  const _test = only
    ? test.cb.only
    : test.cb<commit_msg>adds test for cache purging<commit_after>const test = require('ava')
const Visit = require('./lib/visit')
const sleep = require('sleep-promise')
const url = require('url')

const {
  read,
  file
} = require('./lib/util')

test.cb('environment: should has no errors', t => {
  read(file('nohup.out'))
  .then((content) => {
    console.log(`nohup.out:\n${content}\n`)
    t.is(/error/i.test(content), false)
    t.end()
  })
})

const BACKEND_HOST = 'http://127.0.0.1:8080'
const SLEEP_TOLERANCE = 50

const CASES = [
  {
    d: 'simple request',
    u: '/',
    cache: true,
    expires: false
  },

  {
    d: 'expires',
    u: '/expires-1s',
    h: {
      'Gaia-Expires': '1000'
    },
    expires: 1000,
    cache: true
  },

  {
    d: 'if code is not 200, no cache',
    u: '/no-cache',
    cache: false,
    h: {
      code: 500
    }
  },

  {
    d: 'if http status is not 200, no cache',
    u: '/no-cache',
    cache: false,
    h: {
      status: 500
    }
  },

  {
    d: 'cache purge',
    u: '/test-purge',
    cache: false,
    h: {
      'Gaia-Purge': '1'
    }
  }
]

CASES.forEach(({d, u, cache, expires, only, h, method, b}) => {
  const _test = only
    ? test.cb.only
    : test.cb
{'fraction_non_alphanumeric': 0.1899343544857768, 'fraction_numerical': 0.029321663019693654, 'mean_word_length': 2.2425531914893617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7339912', 'n_tokens_mistral': 967, 'n_tokens_neox': 896, 'n_words': 211}