Browse files

Add test

  • Loading branch information...
1 parent b3754dd commit 4d0a15380b35abf1a775522d811105e0870b91a2 @igorw committed Dec 26, 2012
Showing with 64 additions and 0 deletions.
  1. +4 −0 Makefile
  2. +7 −0 tests/composer-expected.json
  3. +4 −0 tests/composer.yml
  4. +49 −0 tests/yml-to-json-test.sh
View
4 Makefile
@@ -0,0 +1,4 @@
+test:
+ bash tests/yml-to-json-test.sh
+
+.PHONY: test
View
7 tests/composer-expected.json
@@ -0,0 +1,7 @@
+{
+ "name": "foo/bar",
+ "description": "The foobar.",
+ "require": {
+ "baz/qux": "1.0.*@dev"
+ }
+}
View
4 tests/composer.yml
@@ -0,0 +1,4 @@
+name: foo/bar
+description: The foobar.
+require:
+ baz/qux: 1.0.*@dev
View
49 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.