Skip to content

Commit

Permalink
Adding functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yazgazan committed Apr 28, 2017
1 parent 5812ba8 commit 7fbc54f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ script:
- gometalinter --vendored-linters -e '_test.go' ./...
- go test -v ./...
- go test -v -covermode=count -coverprofile=coverage.out ./diff
- ./tests.sh
- $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis-ci -repotoken $COVERALLS_TOKEN

env:
Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status](https://travis-ci.org/yazgazan/jaydiff.svg?branch=master)](https://travis-ci.org/yazgazan/jaydiff)
[![Coverage Status](https://coveralls.io/repos/github/yazgazan/jaydiff/badge.svg?branch=master)](https://coveralls.io/github/yazgazan/jaydiff?branch=master)
[![Go version](https://img.shields.io/badge/go-1.8%2B-brightgreen.svg)](https://github.com/yazgazan/jaydiff)
[![Project version](https://img.shields.io/badge/version-0.1.0-orange.svg)](https://github.com/yazgazan/jaydiff/releases)
[![Project version](https://img.shields.io/badge/version-0.1.1-orange.svg)](https://github.com/yazgazan/jaydiff/releases)

# Install

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
)

const (
statusDiffMismatch = 1
statusUsage = 2
statusReadError = 3
statusUnmarshalError = 4
statusDiffError = 5
statusDiffMismatch = 6
)

func main() {
Expand Down
12 changes: 0 additions & 12 deletions patterns.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package main

import (
"strings"

"github.com/gobwas/glob"
)

Expand All @@ -13,16 +11,6 @@ type ignorePattern struct {

type ignorePatterns []ignorePattern

func (p ignorePatterns) String() string {
var ss []string

for _, pattern := range p {
ss = append(ss, pattern.s)
}

return strings.Join(ss, ",")
}

func (p *ignorePatterns) UnmarshalFlag(s string) error {
pattern, err := glob.Compile(s)
if err != nil {
Expand Down
45 changes: 45 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

FAILED=0

echo "./jaydiff --show-types:"
./jaydiff --indent=' ' --show-types test_files/lhs.json test_files/rhs.json
CODE=$?
if [[ $CODE -ne 6 ]]; then
echo "FAIL with code $CODE"
FAILED=1
else
echo "OK"
fi
echo

echo "./jaydiff --show-types --ignore:"
./jaydiff --indent=' ' --show-types \
--ignore='.b\[\]' --ignore='.d' --ignore='.c.[ac]' \
test_files/lhs.json test_files/rhs.json
CODE=$?
if [[ $CODE -ne 6 ]]; then
echo "FAIL with code $CODE"
FAILED=1
else
echo "OK"
fi
echo

echo "./jaydiff --report --show-types:"
./jaydiff --report --indent=' ' --show-types \
test_files/lhs.json test_files/rhs.json
CODE=$?
if [[ $CODE -ne 6 ]]; then
echo "FAIL with code $CODE"
FAILED=1
else
echo "OK"
fi
echo

if [[ $FAILED -ne 0 ]]; then
echo "$FAILED errors"
exit 1
fi

0 comments on commit 7fbc54f

Please sign in to comment.