<commit_before>function equals(a, b) {
  return !!(EJSON.stringify(a) === EJSON.stringify(b));
}

list = new Meteor.Collection('list');

Tinytest.add('HTTP - publish - client - test environment', function(test) {
  test.isTrue(typeof _publishHTTP === 'undefined', 'test environment initialized _publishHTTP');
  test.isTrue(typeof HTTP !== 'undefined', 'test environment not initialized HTTP');
  test.isTrue(typeof HTTP.publish !== 'undefined', 'test environment not initialized HTTP.publish');
  test.isTrue(typeof HTTP.unpublish !== 'undefined', 'test environment not initialized HTTP.unpublish');
  test.isTrue(typeof HTTP.publishFormats !== 'undefined', 'test environment not initialized HTTP.publishFormats');

});

id = '';
removedId = '';

Tinytest.addAsync('HTTP - publish - client - get list', function (test, onComplete) {

  HTTP.get('http://localhost:3000/api/list', function(err, result) {
    // Test the length of array result
    var len = result.data && result.data.length;
    test.isTrue(!!len, 'Result was empty');
    // Get the object
    var obj = result.data && result.data[0] || {};
    test.equal(obj.text, 'OK', 'Didnt get the expected result');
    // Set the id for the next test
    id = obj._id;
    onComplete();
  });

});

Tinytest.addAsync('HTTP - publish - client - put list', function (test, onComplete) {

  test.isTrue(id !== '', 'No id is set?');

  // Update the data
  HTTP.put('http://localhost:3000/api/list/' + id, {
    data: {
      $set: { text: 'UPDATED' }
    }
  }, function(err, result) {
    var resultId = result.data && result.data._id;
    test.isTrue(resultId !== undefined, 'Didnt get the expected id in result');

    // Check if data is updated
    HTTP.get('http://localhost:3000/api/list', function(err, result) {
      var len = result.data && result.data.length;
      test.isTrue(!!len, 'Result was empty');
      var obj = result.data && result.data[0] || {};
      test.equal(obj.text, 'UPDATED', 'Didnt get the expected result');
      onComplete();
    });
  });

});


Tinytest.addAsync('HTTP - publish - client - insert/remove list', function (test, onComplete) {

  // Insert a doc
  HTTP.post('http://localhost:3000/api/list', {
    data: {
      text: 'INSERTED'
    }
  }, function(err, result) {
    var resultId = result.data && result.data._id;
    test.isTrue(resultId !== undefined, 'Didnt get the expected id in result');
    // Delete the doc
    HTTP.del('http://localhost:3000/api/list/' + resultId, function(err, result) {
      removedId = result.data && result.data._id;
      test.isTrue(removedId !== undefined, 'Didnt get the expected id in result');
      onComplete();
    });
  });

});

Tinytest.addAsync('HTTP - publish - client - check removed', function (test, onComplete) {

  test.isTrue(removedId !== '', 'No removedId is set?');

  HTTP.get('http://localhost:3000/api/list/' + removedId, function(err, result) {
    var obj = result.data || {};
    test.isTrue(obj._id === undefined, 'Item was not removed');
    test.isTrue(err.response.statusCode === 404, 'Item was not removed');
    onComplete();
  });

});


Tinytest.addAsync('HTTP - publish - client - check findOne', function (test, onComplete) {

  test.isTrue(id !== '', 'No id is set?');

  HTTP.get('http://localhost:3000/api/list/' + id, function(err, result) {
    var obj = result.data || {};
    test.isTrue(obj._id !== undefined, 'expected a document');
    test.isTrue(obj.text === 'UPDATED', 'expected text === UPDATED');

    onComplete();
  });

});

<commit_msg>corrected url to relative<commit_after>function equals(a, b) {
  return !!(EJSON.stringify(a) === EJSON.stringify(b));
}

list = new Meteor.Collection('list');

Tinytest.add('HTTP - publish - client - test environment', function(test) {
  test.isTrue(typeof _publishHTTP === 'undefined', 'test environment initialized _publishHTTP');
  test.isTrue(typeof HTTP !== 'undefined', 'test environment not initialized HTTP');
  test.isTrue(typeof HTTP.publish !== 'undefined', 'test environment not initialized HTTP.publish');
  test.isTrue(typeof HTTP.unpublish !== 'undefined', 'test environment not initialized HTTP.unpublish');
  test.isTrue(typeof HTTP.publishFormats !== 'undefined', 'test environment not initialized HTTP.publishFormats');

});

id = '';
removedId = '';

Tinytest.addAsync('HTTP - publish - client - get list', function (test, onComplete) {

  HTTP.get('/api/list', function(err, result) {
    // Test the length of array result
    var len = result.data && result.data.length;
    test.isTrue(!!len, 'Result was empty');
    // Get the object
    var obj = result.data && result.data[0] || {};
    test.equal(obj.text, 'OK', 'Didnt get the expected result');
    // Set the id for the next test
    id = obj._id;
    onComplete();
  });

});

Tinytest.addAsync('HTTP - publish - client - put list', function (test, onComplete) {

  test.isTrue(id !== '', 'No id is set?');

  // Update the data
  HTTP.put('/api/list/' + id, {
    data: {
      $set: { text: 'UPDATED' }
    }
  }, function(err, result) {
    var resultId = result.data && result.data._id;
    test.isTrue(resultId !== undefined, 'Didnt get the expected id in result');

    // Check if data is updated
    HTTP.get('/api/list', function(err, result) {
      var len = result.data && result.data.length;
      test.isTrue(!!len, 'Result was empty');
      var obj = result.data && result.data[0] || {};
      test.equal(obj.text, 'UPDATED', 'Didnt get the expected result');
      onComplete();
    });
  });

});


Tinytest.addAsync('HTTP - publish - client - insert/remove list', function (test, onComplete) {

  // Insert a doc
  HTTP.post('/api/list', {
    data: {
      text: 'INSERTED'
    }
  }, function(err, result) {
    var resultId = result.data && result.data._id;
    test.isTrue(resultId !== undefined, 'Didnt get the expected id in result');
    // Delete the doc
    HTTP.del('/api/list/' + resultId, function(err, result) {
      removedId = result.data && result.data._id;
      test.isTrue(removedId !== undefined, 'Didnt get the expected id in result');
      onComplete();
    });
  });

});

Tinytest.addAsync('HTTP - publish - client - check removed', function (test, onComplete) {

  test.isTrue(removedId !== '', 'No removedId is set?');

  HTTP.get('/api/list/' + removedId, function(err, result) {
    var obj = result.data || {};
    test.isTrue(obj._id === undefined, 'Item was not removed');
    test.isTrue(err.response.statusCode === 404, 'Item was not removed');
    onComplete();
  });

});


Tinytest.addAsync('HTTP - publish - client - check findOne', function (test, onComplete) {

  test.isTrue(id !== '', 'No id is set?');

  HTTP.get('/api/list/' + id, function(err, result) {
    var obj = result.data || {};
    test.isTrue(obj._id !== undefined, 'expected a document');
    test.isTrue(obj.text === 'UPDATED', 'expected text === UPDATED');

    onComplete();
  });

});


{'fraction_non_alphanumeric': 0.17269713132478015, 'fraction_numerical': 0.0054778722790831775, 'mean_word_length': 3.4022842639593907, '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': '1180568', 'n_tokens_mistral': 2195, 'n_tokens_neox': 2158, 'n_words': 571}