{"size": 1151, "ext": "js", "max_stars_repo_path": "test/integration/pricing/proc_meminfo.tap.js", "max_stars_repo_name": "ruguoapp/node-newrelic", "max_stars_repo_stars_event_min_datetime": "2019-05-24T14:11:07.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-24T14:27:05.000Z", "max_issues_repo_path": "test/integration/pricing/proc_meminfo.tap.js", "max_issues_repo_name": "ruguoapp/node-newrelic", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/integration/pricing/proc_meminfo.tap.js", "max_forks_repo_name": "ruguoapp/node-newrelic", "max_forks_repo_forks_event_min_datetime": "2022-03-16T01:38:58.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T01:38:58.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 27.4047619048, "max_line_length": 83, "alphanum_fraction": 0.6238053866}
'use strict'

var a = require('async')
var test = require('tap').test
var glob = require('glob')
var fs = require('fs')
var parseProcMemInfo = require('../../../lib/parse-proc-meminfo')
var path = require('path')

test('pricing proc_meminfo', function(t) {
  var testDir = path.resolve(__dirname, '../../lib/cross_agent_tests/proc_meminfo')
  glob(path.join(testDir, '*.txt'), function(err, data) {
    if (err) throw err
    t.ok(data.length > 0, 'should have tests to run')
    a.each(data, runFile, function(err) {
      t.notOk(err, 'should not have an error')
      t.end()
    })
  })

  function runFile(name, cb) {
    fs.readFile(name, function runTestFiles(err, data) {
      if (err) throw err
      testFile(name, data.toString())
      cb()
    })
  }

  function parseName(name) {
    var pattern = /^meminfo_(\d+)MB.txt$/
    var arr = name.split('/')
    arr = arr[arr.length - 1].replace(pattern, '$1').split(' ')
    return parseInt(arr[0], 10)
  }

  function testFile(name, file) {
    var expected = parseName(name)
    var info = parseProcMemInfo(file)
    t.same(info, expected, "should have expected info with " + name)
  }
})
