go-concourse: fix flaky tests

When golang maps order is not guaranteed, ginkgo url values
matching requires a deep equal i.e. same item with same order,
there is no easy way to test such case

fly: remove unused files

Signed-off-by: Rui Yang <ryang@pivotal.io>
This commit is contained in:
Rui Yang 2019-09-19 12:03:41 -04:00
parent ac5f6b673f
commit a4dad1a420
3 changed files with 2 additions and 53 deletions

View File

@ -1,21 +0,0 @@
package flaghelpers
import (
"encoding/json"
)
type JsonFlag struct {
Raw string
Value map[string]string
}
func (v *JsonFlag) UnmarshalFlag(value string) error {
err := json.Unmarshal([]byte(value), &v.Value)
if err != nil {
return err
}
v.Raw = value
return nil
}

View File

@ -1,30 +0,0 @@
package flaghelpers_test
import (
. "github.com/concourse/concourse/fly/commands/internal/flaghelpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("JsonFlag", func() {
Context("when JSON string is invalid", func() {
It("displays an error message", func() {
jsonFlag := &JsonFlag{}
err := jsonFlag.UnmarshalFlag("{some:value}")
Expect(err).To(MatchError("invalid character 's' looking for beginning of object key string"))
})
})
Context("when JSON string is valid", func() {
It("parse the JSON into version", func() {
jsonFlag := &JsonFlag{}
err := jsonFlag.UnmarshalFlag(`{"some":"value"}`)
Expect(err).ToNot(HaveOccurred())
Expect(jsonFlag.Value).To(Equal(map[string]string{"some": "value"}))
Expect(jsonFlag.Raw).To(Equal(`{"some":"value"}`))
})
})
})

View File

@ -158,11 +158,11 @@ var _ = Describe("ATC Handler Resource Versions", func() {
Context("when filter is specified", func() {
BeforeEach(func() {
filter = atc.Version{"some": "value", "some-other": "other-value"}
filter = atc.Version{"some": "value"}
atcServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", expectedURL, "filter=some:value&filter=some-other:other-value"),
ghttp.VerifyRequest("GET", expectedURL, "filter=some:value"),
ghttp.RespondWithJSONEncoded(http.StatusOK, expectedVersions),
),
)