From 9929e4d4d148724dd31a82a7eed938bc58358663 Mon Sep 17 00:00:00 2001 From: Guillaume de Sagazan Date: Wed, 26 Apr 2017 15:04:26 +0200 Subject: [PATCH] Removing debuging tests from repo --- .gitignore | 1 + tests/lhs.json | 17 ------------ tests/main.go | 73 -------------------------------------------------- tests/rhs.json | 16 ----------- 4 files changed, 1 insertion(+), 106 deletions(-) delete mode 100644 tests/lhs.json delete mode 100644 tests/main.go delete mode 100644 tests/rhs.json diff --git a/.gitignore b/.gitignore index 1550600..2a5cf97 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ jaydiff +tests diff --git a/tests/lhs.json b/tests/lhs.json deleted file mode 100644 index 9d388a2..0000000 --- a/tests/lhs.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "a": 42, - "b": [ - 1, - 2, - 3 - ], - "c": { - "a": "toto", - "b": 23, - "c": [1, 2] - }, - "d": [1, 2], - "e": [], - "f": 42, - "g": [1, 2, 3] -} \ No newline at end of file diff --git a/tests/main.go b/tests/main.go deleted file mode 100644 index 34e33d1..0000000 --- a/tests/main.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "strings" - - "github.com/yazgazan/jaydiff/diff" -) - -func main() { - lhs, err := read("tests/lhs.json") - if err != nil { - panic(err) - } - - rhs, err := read("tests/rhs.json") - if err != nil { - panic(err) - } - - d, err := diff.Diff(lhs, rhs) - if err != nil { - panic(err) - } - - d, err = diff.Walk(d, func(parent diff.Differ, d diff.Differ, path string) (diff.Differ, error) { - if shouldIgnore(path) { - fmt.Println("ignoring") - return &diff.Ignore{}, nil - } - fmt.Printf("%s: %s (ignore: %v)\n", path, d.Diff(), shouldIgnore(path)) - - return nil, nil - }) - if err != nil { - panic(err) - } - - fmt.Println(d.StringIndent("", "", diff.Output{ - Indent: "\t", - Colorized: true, - })) - - if d.Diff() != diff.Identical { - os.Exit(1) - } -} - -func shouldIgnore(path string) bool { - switch path { - case ".e", ".d", ".c.a", ".c.c": - return true - } - - return strings.HasSuffix(path, ".b") -} - -func read(fname string) (interface{}, error) { - var err error - var v interface{} - - b, err := ioutil.ReadFile(fname) - if err != nil { - return nil, err - } - - err = json.Unmarshal(b, &v) - - return v, err -} diff --git a/tests/rhs.json b/tests/rhs.json deleted file mode 100644 index b0d62a3..0000000 --- a/tests/rhs.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "a": 42, - "b": [ - 1, - 2, - 4, - 5 - ], - "c": { - "a": "titi", - "b": "23", - "c": [1] - }, - "d": [1, "2"], - "g": [1, 2, 3] -} \ No newline at end of file