Skip to content

Latest commit

 

History

History
 
 

test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tests

clasp's CLI commands have unit tests that:

  • Run the clasp command
  • Compares the expected stdout text and stderr code

Testing Tools

How to Run Tests

  1. Log in: clasp login
  2. Rebuild: npm run build
  3. Set environmental variables:
    • export TRAVIS_PULL_REQUEST=false
    • export SCRIPT_ID=1EwE84eZCSBPcaAiJzCnDjmxMVnLQrDyhSKq1oZY6q-3x4BIDHgQefCnL
    • export PROJECT_ID=project-id-3961473932623644264
  4. Test: npm run test

Configuration using Travis

Note: The build may fail due to API quota limits. To solve this, wait 24 hours and then rebuild Travis.

Travis automatically build and run tests on clasp for.

Clasp login

Since Travis cannot clasp login, a .clasprc.json file is included that was created locally using clasp login.

Use test account [email protected]. Password is private.

To then encrypt the .clasprc.json file, use these commands using the Travis CLI:

clasp login
cp ~/.clasprc.json ./test/.clasprc.json
travis encrypt-file ./test/.clasprc.json --add

This will add the following line to .travis.yml, which decrypts that file:

openssl aes-256-cbc -K $encrypted_0f9bbf7a60f4_key -iv $encrypted_0f9bbf7a60f4_iv -in .clasprc.json.enc -out .clasprc.json -d || true

Now move .clasprc.json.enc to the /test/ folder:

rm ./test/.clasprc.json.enc
cp .clasprc.json.enc ./test/.clasprc.json.enc
rm ./.clasprc.json.enc

And edit the openssl command in .travis.yml file:

  • Change the -in file to ./test/.clasprc.json.enc
  • Change the -out file to .clasprc.json
  • Add || true to the end of the command

Note: Travis will not decrypt files on a Pull Request from a fork.

There are complicated ways around this. Ideas.

Note: The command ends with || true so Travis doesn't immediately fail on any PR.

Testing Status

This section tracks which clasp commands are tested. Unchecked checkboxes are test cases that still need to be added.

Commands

  • clasp;
  • clasp login';
  • clasp login --no-localhost;
  • clasp logout;
  • clasp create "myTitle"
  • clasp create <untitled>
  • clasp list
  • clasp clone <scriptId>
  • clasp clone
  • clasp pull
  • clasp push
  • echo '// test' >> index.js && clasp push
  • clasp open
  • clasp deployments
  • clasp deploy [version][description]
  • clasp version [description]
  • clasp versions
  • saveProject
  • getScriptURL
  • getLocalFileType
  • getAPIFileType

Configs

  • .js, .gs, .ts files
  • Ignored files