Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Dec 26, 2012
1 parent b3754dd commit 4d0a153
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
@@ -0,0 +1,4 @@
test:
bash tests/yml-to-json-test.sh

.PHONY: test
7 changes: 7 additions & 0 deletions tests/composer-expected.json
@@ -0,0 +1,7 @@
{
"name": "foo/bar",
"description": "The foobar.",
"require": {
"baz/qux": "1.0.*@dev"
}
}
4 changes: 4 additions & 0 deletions tests/composer.yml
@@ -0,0 +1,4 @@
name: foo/bar
description: The foobar.
require:
baz/qux: 1.0.*@dev
49 changes: 49 additions & 0 deletions tests/yml-to-json-test.sh
@@ -0,0 +1,49 @@
#!/bin/bash

function startTests {
echo "PlaygroundUnit 0.0.1 by Igor Wiedler."
echo
}

function endTests {
echo
echo
}

function assertEquals {
if [ "$1" = "$2" ]; then
echo -n .
else
echo "Assertion failed:"
echo "--- Expected"
echo "+++ Actual"
echo "- $1"
echo "+ $2"

endTests
exit 1
fi
}

function assertContentsEquals {
diff="$(diff -u $1 $2)"

if [ "$diff" = "" ]; then
echo -n .
else
echo "Assertion failed:"
echo "$diff"

endTests
exit 1
fi
}

startTests

touch tests/composer-actual.json
bin/composer-yaml convert tests/composer.yml tests/composer-actual.json
assertContentsEquals tests/composer-expected.json tests/composer-actual.json
rm tests/composer-actual.json

endTests

0 comments on commit 4d0a153

Please sign in to comment.