<commit_before>import assert from 'assert';

const findAllData = [{
  id: 0,
  description: 'You have to do something'
}, {
  id: 1,
  description: 'You have to do laundry'
}];

export const Service = {
  events: [ 'log' ],

  find(params, callback) {
    callback(null, findAllData);
  },

  get(name, params, callback) {
    callback(null, {
      id: name,
      description: `You have to do ${name}!`
    });
  },

  create(data, params, callback) {
    let result = Object.assign({}, data, {
      id: 42,
      status: 'created'
    });

    if(Array.isArray(data)) {
      result.many = true;
    }

    callback(null, result);
  },

  update(id, data, params, callback) {
    var result = Object.assign({}, data, {
      id, status: 'updated'
    });

    if(id === null) {
      result.many = true;
    }

    callback(null, result);
  },

  patch(id, data, params, callback) {
    var result = Object.assign({}, data, {
      id, status: 'patched'
    });

    if(id === null) {
      result.many = true;
    }

    callback(null, result);
  },

  remove(id, params, callback) {
    callback(null, { id });
  }
};
<commit_msg>Update test fixture to use promises and add error cases (#19)<commit_after>import assert from 'assert';

const findAllData = [{
  id: 0,
  description: 'You have to do something'
}, {
  id: 1,
  description: 'You have to do laundry'
}];

export const Service = {
  events: [ 'log' ],

  find() {
    return Promise.resolve(findAllData);
  },

  get(name, params) {
    if(params.query.error) {
      return Promise.reject(new Error(`Something for ${name} went wrong`));
    }

    if(params.query.runtimeError) {
      thingThatDoesNotExist(); // jshint ignore:line
    }
    
    return Promise.resolve({
      id: name,
      description: `You have to do ${name}!`
    });
  },

  create(data) {
    const result = Object.assign({}, data, {
      id: 42,
      status: 'created'
    });

    if(Array.isArray(data)) {
      result.many = true;
    }

    return Promise.resolve(result);
  },

  update(id, data) {
    const result = Object.assign({}, data, {
      id, status: 'updated'
    });

    if(id === null) {
      result.many = true;
    }

    return Promise.resolve(result);
  },

  patch(id, data) {
    const result = Object.assign({}, data, {
      id, status: 'patched'
    });

    if(id === null) {
      result.many = true;
    }

    return Promise.resolve(result);
  },

  remove(id) {
    return Promise.resolve({ id });
  }
};

{'fraction_non_alphanumeric': 0.16157556270096463, 'fraction_numerical': 0.0040192926045016075, 'mean_word_length': 2.442600276625173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7278172', 'n_tokens_mistral': 860, 'n_tokens_neox': 825, 'n_words': 210}