benjamintf1 / unmarshalledmatchers Goto Github PK
View Code? Open in Web Editor NEWExpanded matchers for JSON matching
License: MIT License
Expanded matchers for JSON matching
License: MIT License
Thanks for this great library!
One thing that has caused me severe trouble is the naming of the packages and repo. Because it doesn't follow conventions it makes it difficult to install with dep. We have a micro service architecture so I have run into this problem probably 5 times already (Wanted to see if it was something that would go away with practice).
I think this package would have significantly more usage if it were easier to install!
Good package names are short and clear. They are lower case, with no under_scores or mixedCaps. They are often simple nouns...
Hi there :)
We are trying to use MatchUnorderedYAML
to compare two yaml strings, but we are encountering an error.
Here is our code:
package main
import (
. "github.com/Benjamintf1/Expanded-Unmarshalled-Matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("YAML generator", func() {
It("Works with JSON", func() {
Expect(`{"a":[1,2,3]}`).Should(MatchUnorderedJSON(`{"a":[2,1,3]}`))
},
)
It("Works with YAML", func() {
Expect(`a: [1,2,3]`).Should(MatchUnorderedYAML(`a: [2,1,3]`))
})
})
Here is the error we get. The JSON comparison works fine, but the YAML comparison, which we think should be equivalent, errors.
Running Suite: Src Suite
========================
Random Seed: �[1m1526642731�[0m
Will run �[1m2�[0m of �[1m2�[0m specs
�[32m•�[0m
�[90m------------------------------�[0m
�[91m�[1m•! Panic [0.000 seconds]�[0m
YAML generator
�[90m/Users/pivotal/go/src/broke_test.go:9�[0m
�[91m�[1mWorks with YAML [It]�[0m
�[90m/Users/pivotal/go/src/broke_test.go:16�[0m
�[91m�[1mTest Panicked�[0m
�[91mruntime error: comparing uncomparable type map[interface {}]interface {}�[0m
/usr/local/Cellar/go/1.10.2/libexec/src/runtime/panic.go:502
�[91mFull Stack Trace�[0m
/usr/local/Cellar/go/1.10.2/libexec/src/runtime/panic.go:502 +0x229
github.com/Benjamintf1/Expanded-Unmarshalled-Matchers.(*UnmarshalledDeepMatcher).deepEqualRecursive(0xc4200a31e8, 0x139f380, 0xc42009b950, 0x139f380, 0xc42009b860, 0x136c600, 0xc4200971e0, 0x0, 0x0, 0x0)
/Users/pivotal/go/src/github.com/Benjamintf1/Expanded-Unmarshalled-Matchers/unmarshalled_deep_matcher.go:32 +0x36c
github.com/Benjamintf1/Expanded-Unmarshalled-Matchers.(*UnmarshalledDeepMatcher).deepEqual(0xc4200a31e8, 0x139f380, 0xc42009b950, 0x139f380, 0xc42009b860, 0x0, 0x0, 0x0, 0x0)
/Users/pivotal/go/src/github.com/Benjamintf1/Expanded-Unmarshalled-Matchers/unmarshalled_deep_matcher.go:12 +0x5f
github.com/Benjamintf1/Expanded-Unmarshalled-Matchers.(*ExpandedYAMLMatcher).Match(0xc4200a31c0, 0x137e0c0, 0x1458f90, 0xc4200a31c0, 0xc4200571b8, 0x1318055)
/Users/pivotal/go/src/github.com/Benjamintf1/Expanded-Unmarshalled-Matchers/expanded_yaml_matcher.go:34 +0x3e6
github.com/onsi/gomega/internal/assertion.(*Assertion).match(0xc4200a3180, 0x145e3c0, 0xc4200a31c0, 0x1, 0x0, 0x0, 0x0, 0x0)
/Users/pivotal/go/src/github.com/onsi/gomega/internal/assertion/assertion.go:56 +0x62
github.com/onsi/gomega/internal/assertion.(*Assertion).Should(0xc4200a3180, 0x145e3c0, 0xc4200a31c0, 0x0, 0x0, 0x0, 0xc4200a31c0)
/Users/pivotal/go/src/github.com/onsi/gomega/internal/assertion/assertion.go:27 +0xae
_/Users/pivotal/go/src.glob..func1.2()
/Users/pivotal/go/src/broke_test.go:17 +0xc8
github.com/onsi/ginkgo/internal/leafnodes.(*runner).runSync(0xc4200b6540, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/pivotal/go/src/src_suite_test.go:12 +0x64
testing.tRunner(0xc42019a0f0, 0x142c500)
/usr/local/Cellar/go/1.10.2/libexec/src/testing/testing.go:777 +0xd0
created by testing.(*T).Run
/usr/local/Cellar/go/1.10.2/libexec/src/testing/testing.go:824 +0x2e0
�[90m------------------------------�[0m
�[91m�[1mSummarizing 1 Failure:�[0m
�[91m�[1m[Panic!] �[0m�[90mYAML generator �[0m�[91m�[1m[It] Works with YAML �[0m
�[37m/usr/local/Cellar/go/1.10.2/libexec/src/runtime/panic.go:502�[0m
�[1m�[91mRan 2 of 2 Specs in 0.001 seconds�[0m
�[1m�[91mFAIL!�[0m -- �[32m�[1m1 Passed�[0m | �[91m�[1m1 Failed�[0m | �[33m�[1m0 Pending�[0m | �[36m�[1m0 Skipped�[0m
--- FAIL: TestSrc (0.00s)
FAIL
Ginkgo ran 1 suite in 867.419953ms
Test Suite Failed
Could this be a problem with the YAML parsing? Or perhaps we're missing something :)
Hi, would support for XML be something you'd be happy to add? we've already got some of the code but are maintaining it separately, so would be able to create a PR
I literally had a need for this and the documentation pointed me here. I was wondering why we didn't just merge this (if you were so inclined).
Hi, I love the matcher. Really makes api testing a breeze. It would be awesome if the error message included a diff of the expected json and the actual json. When there is a large chunk of json text it can be hard to find what the difference is between the two.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.