Code Monkey home page Code Monkey logo

pipetest's Introduction

⛲ Pipetest

Build Status License

Pipetest is a simple and lightweight set of shell functions useful to implement assertions with I/O Redirection.

Why Pipetest?

Thanks to the use of Piping it will be possible to create scripts that are easy to read and able to be understood by a wide audience. This makes Pipetest suitable for the following scenarios

  • CI/CD Pipelines
  • Ansible Playbooks
  • Automated Testing
  • Data Processing

In other words, everything that can refer to this

./build-something.sh | assert_equals "done."`

Suppoerted Shells

We try to do everything possible to ensure maximum compatibility with these platforms

bash bosh busybox dash ksh mksh posh yash zsh

Get Started

Pipetest is just one file, put the file pipetest.sh into your project then load as source into your script.

Installation

$ curl -o pipetest.sh https://github.com/javanile/pipetest/releases/download/v0.1.0/pipetest.sh
#!/usr/bin/env bash
set -e

source pipetest.sh

echo "Hello World!" | assert_equals "Hello World!"

Documentation

There are the lists of supported functions


assert_empty

Fails if piped output is not empty.

Usage

... | assert_empty [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

echo "" | assert_empty
ls | assert_empty "Current directory is not empty"
cat apache2.log | assert_empty "Log file is not empty"

➡ | assert_empty

Usage

... | assert_empty [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

echo "" | assert_empty
ls | assert_empty
cat apache2.log | assert_empty

➡ | assert_file_exists

Usage

assert_file_exists [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

touch sample_file.txt
assert_file_exists sample_file.txt
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong."
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong." "Ok! it working."

➡ | assert_file_exists

Usage

assert_file_exists [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

touch sample_file.txt
assert_file_exists sample_file.txt
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong."
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong." "Ok! it working."

➡ | assert_file_exists

Usage

assert_file_exists [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

touch sample_file.txt
assert_file_exists sample_file.txt
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong."
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong." "Ok! it working."

➡ | assert_directory_exists

Usage

assert_file_exists [FAIL_MESSAGE] [SUCCESS_MESSAGE]

Examples

touch sample_file.txt
assert_file_exists sample_file.txt
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong."
mv old_file_name.txt new_file_name.txt
assert_file_exists new_file_name.txt "Moving file goes wrong." "Ok! it working."

Contributing

See CONTRIBUTING.md in the repo, obviously pull-request are welcome.

Community & Questions

  • GitHub Issues: report a bug or raise a feature request to the Pipetest core team
  • StackOverflow Tag: see existing Q&A for BASH and Unit Testing. We look at them often

License

Pipetest is open-sourced software licensed under the MIT license.

pipetest's People

Contributors

francescobianco avatar sweep-ai[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

pipetest's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.