<commit_before>#!/bin/bash

# Colors
red () {
  echo "\033[31m"$@
}

green () {
  echo "\033[01;32m"$@
}

# Helpers
valid () {
  eval $@ > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    [ -z "$TRAVIS" ] && green "SUCCESS" || echo "SUCCESS"
    return 0
  else
    [ -z "$TRAVIS" ] && red "FAILED" || echo "FAILED"
    return 1
  fi
}

# URL Possibilities
URL="https://admin:synology@demo.synology.com:5001"
URL_WRONG_PROTOCOL="ftp://synology@demo.synology.com:5001"
URL_NO_PORT="https://admin:synology@demo.synology.com"
URL_NO_PORT_NO_AUTH="demo.synology.com"

# Link to a file of zero bytes length
# http://www.wikiwand.com/en/Magnet_URI_scheme
MAGNET_LINK="magnet:?xt=urn:ed2k:31D6CFE0D16AE931B73C59D7E0C089C0&xl=0&dn=zero_len.fil&xt=urn:bitprint:3I42H3S6NNFQ2MSVX7XZKYAYSCX5QBYJ.LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ&xt=urn:md5:D41D8CD98F00B204E9800998ECF8427E"

# A high quality 5 minute MP3 music file
# http://www.thinkbroadband.com/download.html
HTTP_FILE="http://download.thinkbroadband.com/5MB.zip"

# Tests
# Syntax: valid cmd [options] Exit code 0 (Success) expected.
# Syntax: valid ! cmd [options] Exit code 1 (Failure) expected.
echo "Begin Tests CLI :" `date`

valid "! node bin/syno.js wrong_command getFileStationInfo -u $URL -d" &&
valid "! node bin/syno.js fs wrong_method -u $URL -d" &&
valid "! node bin/syno.js wrong_method -u $URL -d" &&
valid "node bin/syno.js fs getFileStationInfo -u $URL -d" &&
valid "! node bin/syno.js fs getFileStationInfo -u $URL_WRONG_PROTOCOL -d" &&
valid "node bin/syno.js fs getFileStationInfo -u $URL_NO_PORT -d" &&
valid "node bin/syno.js fs getFileStationInfo -u $URL_NO_PORT_NO_AUTH -d" &&
valid "node bin/syno.js dl getDownloadStationInfo -u $URL -d" &&
valid "node bin/syno.js fs listSharedFolders -u $URL -d" &&
valid "node bin/syno.js fs listFiles -p '{\"folder_path\":\"/photo\"}' -u $URL -d" &&
valid "node bin/syno.js fs listFiles -p '{\"folder_path\":\"/photo\"}' -u $URL -P -d" &&
valid "node bin/syno.js dl listTasks -u $URL -d" &&
valid "node bin/syno.js dl listTasks -p '{\"limit\":0}' -u $URL -d" &&
valid "node bin/syno.js dl getStats -u $URL -d" &&
valid "node bin/syno.js downloadstation getStats -u $URL -d" &&
valid "node bin/syno.js dl createTask -u $URL -p '{\"uri\":\"$MAGNET_LINK\"}' -d" &&
valid "node bin/syno.js dl createTask -u $URL -p '{\"uri\":\"$HTTP_FILE\"}' -d" &&
valid "node bin/syno.js as getAudioStationInfo -u $URL -d" &&
valid "node bin/syno.js as listSongs -u $URL -p '{\"limit\":2}' -P -d"

echo "End Tests CLI :" `date`<commit_msg>Remove API tests in CLI and keeps only CLI syntax tests<commit_after>#!/bin/bash

# Colors
red () {
  echo "\033[31m"$@
}

green () {
  echo "\033[01;32m"$@
}

# Helpers
valid () {
  eval $@ > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    [ -z "$TRAVIS" ] && green "SUCCESS" || echo "SUCCESS"
    return 0
  else
    [ -z "$TRAVIS" ] && red "FAILED" || echo "FAILED"
    return 1
  fi
}

# URL Possibilities
URL="https://admin:synology@demo.synology.com:5001"
URL_WRONG_PROTOCOL="ftp://synology@demo.synology.com:5001"
URL_NO_PORT="https://admin:synology@demo.synology.com"
URL_NO_PORT_NO_AUTH="demo.synology.com"

# Tests
# Syntax: valid cmd [options] Exit code 0 (Success) expected.
# Syntax: valid ! cmd [options] Exit code 1 (Failure) expected.
echo "Begin Tests CLI :" `date`

valid "node bin/syno.js -u $URL -h" &&
valid "node bin/syno.js -u $URL -V" &&
valid "! node bin/syno.js fs -c wrong_path" &&
valid "touch config_file.yaml && ! node bin/syno.js fs -c config_file.yaml && rm config_file.yaml" &&
valid "! node bin/syno.js wrong_command getFileStationInfo -u $URL -d" &&
valid "! node bin/syno.js fs wrong_method -u $URL -d" &&
valid "! node bin/syno.js wrong_command -u $URL -d" &&
valid "! node bin/syno.js fs getFileStationInfo -u $URL_WRONG_PROTOCOL -d" &&
valid "node bin/syno.js fs getFileStationInfo -u $URL_NO_PORT -d" &&
valid "node bin/syno.js fs getFileStationInfo -u $URL_NO_PORT_NO_AUTH -d"

echo "End Tests CLI :" `date`
{'fraction_non_alphanumeric': 0.1708238851095994, 'fraction_numerical': 0.028470647518266567, 'mean_word_length': 3.9439601494396017, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2592683', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1610, 'n_words': 409}