Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iOliverNguyen committed Jun 2, 2018
0 parents commit 10bc073
Show file tree
Hide file tree
Showing 8 changed files with 653 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__*
.DS_Store
.vscode
*.test
bin
debug*
vendor
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: go
go_import_path: github.com/ng-vu/goconveyx
go:
- 1.8.x
- 1.9.x
- 1.10.x
- tip
sudo: false
install:
- go get -u github.com/golang/dep/cmd/dep
- dep ensure
- go get github.com/alecthomas/gometalinter
- gometalinter --install
script:
- export PATH=$PATH:$HOME/gopath/bin
- export GORACE="halt_on_error=1"
- test -z "$(gometalinter --disable-all
--enable=gofmt
--enable=golint
--enable=vet
--enable=gosimple
--enable=unconvert
--deadline=4m . | tee /dev/stderr)"
- go test -v -race .
- go test -v -race . -covermode=atomic -coverprofile=profile.cover
after_success:
- go get -v github.com/mattn/goveralls
- goveralls -coverprofile=profile.cover -service=travis-ci
53 changes: 53 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/davecgh/go-spew"
version = "1.1.0"

[[constraint]]
name = "github.com/go-test/deep"
version = "1.0.1"

[[constraint]]
name = "github.com/smartystreets/goconvey"
version = "1.6.3"

[prune]
go-tests = true
unused-packages = true
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License

Copyright (c) 2018-NOW Vu Nguyen <olvrng@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# GoconveyX

[![Build Status](https://travis-ci.org/ng-vu/goconveyx.svg?branch=master)](https://travis-ci.org/ng-vu/goconveyx)
[![Coverage Status](https://coveralls.io/repos/github/ng-vu/goconveyx/badge.svg?branch=master)](https://coveralls.io/github/ng-vu/goconveyx?branch=master)

GoconveyX extends [goconvey](https://github.com/smartystreets/goconvey) by
providing a few more functions:

- ShouldDeepEqual
- ShouldResembleSlice
- ShouldResembleByKey

# Documentation

[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/ng-vu/goconveyx)

### ShouldDeepEqual

`ShouldDeepEqual` is the same as
[ShouldResemble](https://godoc.org/github.com/smartystreets/assertions#ShouldResemble)
with better error message.

### ShouldResembleSlice

`ShouldResembleSlice` does deep equal comparison on two slices without ordering.

```go
ShouldResembleSlice([]int{1, 2, 3}, []int{1, 2, 3}) // true
ShouldResembleSlice([]int{1, 2, 3}, []int{3, 1, 2}) // true
ShouldResembleSlice([]int{1, 2, 3}, []int{1, 2, 3, 1}) // false
```

### ShouldResembleByKey

`ShouldResembleByKey` does deep equal comparison on two slices sorted by given
key. It works on slices with map and struct as element. It's useful when you
want to compare rows retrieved from database.

```go
type M map[string]interface{}

ShouldResembleByKey("id")(
[]M{{"id": 1, "v": 10}, {"id": 2, "v": 20}},
[]M{{"id": 2, "v": 20}, {"id": 1, "v": 10}},
) // true

ShouldResembleByKey("id")(
[]M{{"id": 1, "v": 10}, {"id": 2, "v": 20}},
[]M{{"id": 2, "v": 10}, {"id": 1, "v": 20}},
) // false
```

# License

- [MIT License](https://opensource.org/licenses/mit-license.php)

0 comments on commit 10bc073

Please sign in to comment.