HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/server/nodejs/v18.20.6/lib/node_modules/pm2/node_modules/js-git/test/test-config-codec.js
var run = require('./run.js');

// The thing we mean to test.
var codec = require('../lib/config-codec.js');

var sample = '\
[user]\n\
\tname = Tim Caswell\n\
\temail = tim@creationix.com\n\
[core]\n\
\teditor = vim\n\
\twhitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol\n\
[web]\n\
\tbrowser = google-chrome\n\
[color]\n\
\tui = true\n\
[color "branch"]\n\
\tcurrent = yellow bold\n\
\tlocal = green bold\n\
\tremote = cyan bold\n\
[color "diff"]\n\
\tmeta = yellow bold\n\
\tfrag = magenta bold\n\
\told = red bold\n\
\tnew = green bold\n\
\twhitespace = red reverse\n\
[github]\n\
\tuser = creationix\n\
\ttoken = token';

var config;

run([
  function testDecode() {
    config = codec.decode(sample);
    if (config.user.name !== "Tim Caswell") {
      throw new Error("Failed to parse user.name");
    }
    if (config.color.ui != "true") {
      throw new Error("Failed to parse color.ui");
    }
    if (config.color.diff.meta !== "yellow bold") {
      throw new Error("Failed to parse color.diff.meta");
    }
  },
  function testEncode() {
    var encoded = codec.encode(config);
    var config2 = codec.decode(encoded);
    if (JSON.stringify(config) !== JSON.stringify(config2)) {
      console.log(config);
      console.log(encoded);
      console.log(config2);
      throw new Error("Encode failed");
    }
  },
  function testEncode2() {
    var encoded = codec.encode({
      foo: {
        bar: {
          baz: true
        }
      }
    });
    if (encoded !== '[foo "bar"]\n\tbaz = true\n') {
      console.log(encoded);
      throw new Error("Invalid encoding of single deep config");
    }
  }
]);