Skip to content

Commit

Permalink
Use gotest.tools/golden to simplify test file loading
Browse files Browse the repository at this point in the history
"dep ensure" also bumped some dependencies
  • Loading branch information
Eric Hu authored and Zachary Scott committed Aug 31, 2018
1 parent a7159ae commit 162afbd
Show file tree
Hide file tree
Showing 26 changed files with 4,373 additions and 9 deletions.
29 changes: 29 additions & 0 deletions Gopkg.lock

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

15 changes: 6 additions & 9 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

"io"

"gotest.tools/golden"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
Expand Down Expand Up @@ -1081,23 +1083,18 @@ var _ = Describe("Orb integration tests", func() {

It("makes a namespace query and requests all orbs on that namespace", func() {
By("setting up a mock server")

// These requests and responses are generated from production data,
// but using a 5-per-page limit instead of the 20 requested.
tmpBytes, err := ioutil.ReadFile(filepath.Join("testdata/gql_orb_list_with_namespace", "first_request.json"))
Expect(err).ShouldNot(HaveOccurred())
tmpBytes := golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_with_namespace/first_request.json"))
firstGqlRequest := string(tmpBytes)

tmpBytes, err = ioutil.ReadFile(filepath.Join("testdata/gql_orb_list_with_namespace", "second_request.json"))
Expect(err).ShouldNot(HaveOccurred())
tmpBytes = golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_with_namespace/second_request.json"))
secondGqlRequest := string(tmpBytes)

tmpBytes, err = ioutil.ReadFile(filepath.Join("testdata/gql_orb_list_with_namespace", "first_response.json"))
Expect(err).ShouldNot(HaveOccurred())
tmpBytes = golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_with_namespace/first_response.json"))
firstGqlResponse := string(tmpBytes)

tmpBytes, err = ioutil.ReadFile(filepath.Join("testdata/gql_orb_list_with_namespace", "second_response.json"))
Expect(err).ShouldNot(HaveOccurred())
tmpBytes = golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_with_namespace/second_response.json"))
secondGqlResponse := string(tmpBytes)

// Use Gomega's default matcher instead of our custom appendPostHandler
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/google/go-cmp/LICENSE

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

Loading

0 comments on commit 162afbd

Please sign in to comment.