Bump github.com/onsi/gomega from 1.9.0 to 1.10.0
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.9.0...v1.10.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
1ec2ccf5f3
commit
461f6406d9
|
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/docker/docker v1.4.2-0.20191219165747-a9416c67da9f
|
||||
github.com/docker/go-units v0.4.0
|
||||
github.com/onsi/ginkgo v1.12.0
|
||||
github.com/onsi/gomega v1.9.0
|
||||
github.com/onsi/gomega v1.10.0
|
||||
github.com/opencontainers/runc v1.0.0-rc9
|
||||
github.com/opencontainers/runtime-spec v0.1.2-0.20190618234442-a950415649c7 // indirect
|
||||
github.com/opencontainers/selinux v1.5.1
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
|||
github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
|
||||
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg=
|
||||
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
|
||||
github.com/onsi/gomega v1.10.0 h1:Gwkk+PTu/nfOwNMtUB/mRUv0X7ewW5dO4AERT1ThVKo=
|
||||
github.com/onsi/gomega v1.10.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
|
||||
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import (
|
|||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
gomega.RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Config Suite")
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ func beforeEach() {
|
|||
|
||||
func defaultConfig() *Config {
|
||||
c, err := DefaultConfig()
|
||||
Expect(err).To(BeNil())
|
||||
Expect(c).NotTo(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(c).NotTo(gomega.BeNil())
|
||||
return c
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/containers/common/pkg/capabilities"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega"
|
||||
selinux "github.com/opencontainers/selinux/go-selinux"
|
||||
)
|
||||
|
||||
|
|
@ -23,9 +23,9 @@ var _ = Describe("Config", func() {
|
|||
defaultConfig, err := NewConfig("")
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(defaultConfig.Containers.ApparmorProfile).To(Equal("container-default"))
|
||||
Expect(defaultConfig.Containers.PidsLimit).To(BeEquivalentTo(2048))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(defaultConfig.Containers.ApparmorProfile).To(gomega.Equal("container-default"))
|
||||
gomega.Expect(defaultConfig.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
|
||||
})
|
||||
|
||||
It("should succeed with devices", func() {
|
||||
|
|
@ -40,7 +40,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on wrong DefaultUlimits", func() {
|
||||
|
|
@ -51,7 +51,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on wrong invalid device specification", func() {
|
||||
|
|
@ -62,7 +62,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid device", func() {
|
||||
|
|
@ -73,7 +73,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid device mode", func() {
|
||||
|
|
@ -84,7 +84,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid first device", func() {
|
||||
|
|
@ -95,7 +95,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid second device", func() {
|
||||
|
|
@ -106,7 +106,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Containers.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail wrong max log size", func() {
|
||||
|
|
@ -117,7 +117,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should succeed with valid shm size", func() {
|
||||
|
|
@ -128,7 +128,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
|
||||
// Given
|
||||
sut.Containers.ShmSize = "64m"
|
||||
|
|
@ -137,7 +137,7 @@ var _ = Describe("Config", func() {
|
|||
err = sut.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail wrong shm size", func() {
|
||||
|
|
@ -148,18 +148,18 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("Check SELinux settings", func() {
|
||||
if selinux.GetEnabled() {
|
||||
sut.Containers.EnableLabeling = true
|
||||
Expect(sut.Containers.Validate()).To(BeNil())
|
||||
Expect(selinux.GetEnabled()).To(BeTrue())
|
||||
gomega.Expect(sut.Containers.Validate()).To(gomega.BeNil())
|
||||
gomega.Expect(selinux.GetEnabled()).To(gomega.BeTrue())
|
||||
|
||||
sut.Containers.EnableLabeling = false
|
||||
Expect(sut.Containers.Validate()).To(BeNil())
|
||||
Expect(selinux.GetEnabled()).To(BeFalse())
|
||||
gomega.Expect(sut.Containers.Validate()).To(gomega.BeNil())
|
||||
gomega.Expect(selinux.GetEnabled()).To(gomega.BeFalse())
|
||||
}
|
||||
|
||||
})
|
||||
|
|
@ -173,7 +173,7 @@ var _ = Describe("Config", func() {
|
|||
err := sut.Network.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail during runtime", func() {
|
||||
|
|
@ -192,14 +192,14 @@ var _ = Describe("Config", func() {
|
|||
err = sut.Network.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).ToNot(BeNil())
|
||||
gomega.Expect(err).ToNot(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid NetworkConfigDir", func() {
|
||||
// Given
|
||||
tmpfile := path.Join(os.TempDir(), "wrong-file")
|
||||
file, err := os.Create(tmpfile)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
file.Close()
|
||||
defer os.Remove(tmpfile)
|
||||
sut.Network.NetworkConfigDir = tmpfile
|
||||
|
|
@ -209,7 +209,7 @@ var _ = Describe("Config", func() {
|
|||
err = sut.Network.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail on invalid CNIPluginDirs", func() {
|
||||
|
|
@ -226,7 +226,7 @@ var _ = Describe("Config", func() {
|
|||
err = sut.Network.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail in validating invalid PluginDir", func() {
|
||||
|
|
@ -243,7 +243,7 @@ var _ = Describe("Config", func() {
|
|||
err = sut.Network.Validate()
|
||||
|
||||
// Then
|
||||
Expect(err).ToNot(BeNil())
|
||||
gomega.Expect(err).ToNot(gomega.BeNil())
|
||||
})
|
||||
|
||||
})
|
||||
|
|
@ -294,13 +294,13 @@ var _ = Describe("Config", func() {
|
|||
}
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(defaultConfig.Engine.CgroupManager).To(Equal("systemd"))
|
||||
Expect(defaultConfig.Containers.Env).To(BeEquivalentTo(envs))
|
||||
Expect(defaultConfig.Containers.PidsLimit).To(BeEquivalentTo(2048))
|
||||
Expect(defaultConfig.Network.CNIPluginDirs).To(Equal(pluginDirs))
|
||||
Expect(defaultConfig.Engine.NumLocks).To(BeEquivalentTo(2048))
|
||||
Expect(defaultConfig.Engine.OCIRuntimes).To(Equal(OCIRuntimeMap))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(defaultConfig.Engine.CgroupManager).To(gomega.Equal("systemd"))
|
||||
gomega.Expect(defaultConfig.Containers.Env).To(gomega.BeEquivalentTo(envs))
|
||||
gomega.Expect(defaultConfig.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
|
||||
gomega.Expect(defaultConfig.Network.CNIPluginDirs).To(gomega.Equal(pluginDirs))
|
||||
gomega.Expect(defaultConfig.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
|
||||
gomega.Expect(defaultConfig.Engine.OCIRuntimes).To(gomega.Equal(OCIRuntimeMap))
|
||||
})
|
||||
|
||||
It("should succeed with commented out configuration", func() {
|
||||
|
|
@ -310,7 +310,7 @@ var _ = Describe("Config", func() {
|
|||
_, err := readConfigFromFile("testdata/containers_comment.conf", &conf)
|
||||
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail when file does not exist", func() {
|
||||
|
|
@ -320,7 +320,7 @@ var _ = Describe("Config", func() {
|
|||
_, err := readConfigFromFile("/invalid/file", &conf)
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("should fail when toml decode fails", func() {
|
||||
|
|
@ -330,7 +330,7 @@ var _ = Describe("Config", func() {
|
|||
_, err := readConfigFromFile("config.go", &conf)
|
||||
|
||||
// Then
|
||||
Expect(err).NotTo(BeNil())
|
||||
gomega.Expect(err).NotTo(gomega.BeNil())
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -373,13 +373,13 @@ var _ = Describe("Config", func() {
|
|||
// When
|
||||
config, err := NewConfig("")
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(config.Containers.ApparmorProfile).To(Equal("container-default"))
|
||||
Expect(config.Containers.PidsLimit).To(BeEquivalentTo(2048))
|
||||
Expect(config.Containers.Env).To(BeEquivalentTo(envs))
|
||||
Expect(config.Network.CNIPluginDirs).To(Equal(pluginDirs))
|
||||
Expect(config.Engine.NumLocks).To(BeEquivalentTo(2048))
|
||||
Expect(config.Engine.OCIRuntimes["runc"]).To(Equal(OCIRuntimeMap["runc"]))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("container-default"))
|
||||
gomega.Expect(config.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
|
||||
gomega.Expect(config.Containers.Env).To(gomega.BeEquivalentTo(envs))
|
||||
gomega.Expect(config.Network.CNIPluginDirs).To(gomega.Equal(pluginDirs))
|
||||
gomega.Expect(config.Engine.NumLocks).To(gomega.BeEquivalentTo(2048))
|
||||
gomega.Expect(config.Engine.OCIRuntimes["runc"]).To(gomega.Equal(OCIRuntimeMap["runc"]))
|
||||
})
|
||||
|
||||
It("verify getDefaultEnv", func() {
|
||||
|
|
@ -390,20 +390,20 @@ var _ = Describe("Config", func() {
|
|||
// When
|
||||
config, err := Default()
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(config.GetDefaultEnv()).To(BeEquivalentTo(envs))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(config.GetDefaultEnv()).To(gomega.BeEquivalentTo(envs))
|
||||
config.Containers.HTTPProxy = true
|
||||
Expect(config.GetDefaultEnv()).To(BeEquivalentTo(envs))
|
||||
gomega.Expect(config.GetDefaultEnv()).To(gomega.BeEquivalentTo(envs))
|
||||
os.Setenv("HTTP_PROXY", "localhost")
|
||||
os.Setenv("FOO", "BAR")
|
||||
newenvs := []string{"HTTP_PROXY=localhost"}
|
||||
envs = append(newenvs, envs...)
|
||||
Expect(config.GetDefaultEnv()).To(BeEquivalentTo(envs))
|
||||
gomega.Expect(config.GetDefaultEnv()).To(gomega.BeEquivalentTo(envs))
|
||||
config.Containers.HTTPProxy = false
|
||||
config.Containers.EnvHost = true
|
||||
envString := strings.Join(config.GetDefaultEnv(), ",")
|
||||
Expect(envString).To(ContainSubstring("FOO=BAR"))
|
||||
Expect(envString).To(ContainSubstring("HTTP_PROXY=localhost"))
|
||||
gomega.Expect(envString).To(gomega.ContainSubstring("FOO=BAR"))
|
||||
gomega.Expect(envString).To(gomega.ContainSubstring("HTTP_PROXY=localhost"))
|
||||
})
|
||||
|
||||
It("should success with valid user file path", func() {
|
||||
|
|
@ -411,9 +411,9 @@ var _ = Describe("Config", func() {
|
|||
// When
|
||||
config, err := NewConfig("testdata/containers_default.conf")
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(config.Containers.ApparmorProfile).To(Equal("container-default"))
|
||||
Expect(config.Containers.PidsLimit).To(BeEquivalentTo(2048))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("container-default"))
|
||||
gomega.Expect(config.Containers.PidsLimit).To(gomega.BeEquivalentTo(2048))
|
||||
})
|
||||
|
||||
It("contents of passed-in file should override others", func() {
|
||||
|
|
@ -429,9 +429,9 @@ var _ = Describe("Config", func() {
|
|||
os.Unsetenv("CONTAINERS_CONF")
|
||||
}
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
Expect(config).ToNot(BeNil())
|
||||
Expect(config.Containers.ApparmorProfile).To(Equal("overridden-default"))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(config).ToNot(gomega.BeNil())
|
||||
gomega.Expect(config.Containers.ApparmorProfile).To(gomega.Equal("overridden-default"))
|
||||
})
|
||||
|
||||
It("should fail with invalid value", func() {
|
||||
|
|
@ -439,8 +439,8 @@ var _ = Describe("Config", func() {
|
|||
// When
|
||||
config, err := NewConfig("testdata/containers_invalid.conf")
|
||||
// Then
|
||||
Expect(err).ToNot(BeNil())
|
||||
Expect(config).To(BeNil())
|
||||
gomega.Expect(err).ToNot(gomega.BeNil())
|
||||
gomega.Expect(config).To(gomega.BeNil())
|
||||
})
|
||||
|
||||
It("Test Capabilities call", func() {
|
||||
|
|
@ -448,28 +448,28 @@ var _ = Describe("Config", func() {
|
|||
// When
|
||||
config, err := NewConfig("")
|
||||
// Then
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
var addcaps, dropcaps []string
|
||||
caps, err := config.Capabilities("0", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
defaultCaps := config.Containers.DefaultCapabilities
|
||||
sort.Strings(defaultCaps)
|
||||
Expect(caps).To(BeEquivalentTo(defaultCaps))
|
||||
gomega.Expect(caps).To(gomega.BeEquivalentTo(defaultCaps))
|
||||
|
||||
// Add all caps
|
||||
addcaps = []string{"all"}
|
||||
caps, err = config.Capabilities("root", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
Expect(caps).To(BeEquivalentTo(capabilities.AllCapabilities()))
|
||||
gomega.Expect(caps).To(gomega.BeEquivalentTo(capabilities.AllCapabilities()))
|
||||
|
||||
// Drop all caps
|
||||
dropcaps = []string{"all"}
|
||||
caps, err = config.Capabilities("", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
Expect(caps).ToNot(BeEquivalentTo([]string{}))
|
||||
gomega.Expect(caps).ToNot(gomega.BeEquivalentTo([]string{}))
|
||||
|
||||
config.Containers.DefaultCapabilities = []string{
|
||||
"CAP_AUDIT_WRITE",
|
||||
|
|
@ -489,37 +489,37 @@ var _ = Describe("Config", func() {
|
|||
addcaps = []string{"CAP_NET_ADMIN", "CAP_SYS_ADMIN"}
|
||||
dropcaps = []string{"CAP_FOWNER", "CAP_CHOWN"}
|
||||
caps, err = config.Capabilities("", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
Expect(caps).To(BeEquivalentTo(expectedCaps))
|
||||
gomega.Expect(caps).To(gomega.BeEquivalentTo(expectedCaps))
|
||||
|
||||
addcaps = []string{"NET_ADMIN", "cap_sys_admin"}
|
||||
dropcaps = []string{"FOWNER", "chown"}
|
||||
caps, err = config.Capabilities("", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
Expect(caps).To(BeEquivalentTo(expectedCaps))
|
||||
gomega.Expect(caps).To(gomega.BeEquivalentTo(expectedCaps))
|
||||
|
||||
expectedCaps = []string{"CAP_NET_ADMIN", "CAP_SYS_ADMIN"}
|
||||
caps, err = config.Capabilities("notroot", addcaps, dropcaps)
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
sort.Strings(caps)
|
||||
Expect(caps).To(BeEquivalentTo(expectedCaps))
|
||||
gomega.Expect(caps).To(gomega.BeEquivalentTo(expectedCaps))
|
||||
})
|
||||
|
||||
It("should succeed with default pull_policy", func() {
|
||||
err := sut.Engine.Validate()
|
||||
Expect(err).To(BeNil())
|
||||
Expect(sut.Engine.PullPolicy).To(Equal("missing"))
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
gomega.Expect(sut.Engine.PullPolicy).To(gomega.Equal("missing"))
|
||||
|
||||
sut.Engine.PullPolicy = DefaultPullPolicy
|
||||
err = sut.Engine.Validate()
|
||||
Expect(err).To(BeNil())
|
||||
gomega.Expect(err).To(gomega.BeNil())
|
||||
})
|
||||
It("should fail with invalid pull_policy", func() {
|
||||
sut.Engine.PullPolicy = "invalidPullPolicy"
|
||||
err := sut.Engine.Validate()
|
||||
Expect(err).ToNot(BeNil())
|
||||
gomega.Expect(err).ToNot(gomega.BeNil())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.12.x
|
||||
- 1.13.x
|
||||
- 1.14.x
|
||||
- gotip
|
||||
|
||||
env:
|
||||
|
|
|
|||
|
|
@ -1,3 +1,11 @@
|
|||
## 1.10.0
|
||||
|
||||
### Features
|
||||
- Add HaveHTTPStatusMatcher (#378) [f335c94]
|
||||
- Changed matcher for content-type in VerifyJSONRepresenting (#377) [6024f5b]
|
||||
- Make ghttp usable with x-unit style tests (#376) [c0be499]
|
||||
- Implement PanicWith matcher (#381) [f8032b4]
|
||||
|
||||
## 1.9.0
|
||||
|
||||
### Features
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/onsi/gomega/types"
|
||||
)
|
||||
|
||||
const GOMEGA_VERSION = "1.9.0"
|
||||
const GOMEGA_VERSION = "1.10.0"
|
||||
|
||||
const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
|
||||
If you're using Ginkgo then you probably forgot to put your assertion in an It().
|
||||
|
|
@ -252,7 +252,7 @@ func Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion {
|
|||
return ConsistentlyWithOffset(0, actual, intervals...)
|
||||
}
|
||||
|
||||
// ConsistentlyWithOffset operates like Consistnetly but takes an additional
|
||||
// ConsistentlyWithOffset operates like Consistently but takes an additional
|
||||
// initial argument to indicate an offset in the call stack. This is useful when building helper
|
||||
// functions that contain matchers. To learn more, read about `ExpectWithOffset`.
|
||||
func ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interface{}) AsyncAssertion {
|
||||
|
|
@ -432,3 +432,32 @@ func toDuration(input interface{}) time.Duration {
|
|||
|
||||
panic(fmt.Sprintf("%v is not a valid interval. Must be time.Duration, parsable duration string or a number.", input))
|
||||
}
|
||||
|
||||
// Gomega describes the essential Gomega DSL. This interface allows libraries
|
||||
// to abstract between the standard package-level function implementations
|
||||
// and alternatives like *WithT.
|
||||
type Gomega interface {
|
||||
Expect(actual interface{}, extra ...interface{}) Assertion
|
||||
Eventually(actual interface{}, intervals ...interface{}) AsyncAssertion
|
||||
Consistently(actual interface{}, intervals ...interface{}) AsyncAssertion
|
||||
}
|
||||
|
||||
type globalFailHandlerGomega struct{}
|
||||
|
||||
// DefaultGomega supplies the standard package-level implementation
|
||||
var Default Gomega = globalFailHandlerGomega{}
|
||||
|
||||
// Expect is used to make assertions. See documentation for Expect.
|
||||
func (globalFailHandlerGomega) Expect(actual interface{}, extra ...interface{}) Assertion {
|
||||
return Expect(actual, extra...)
|
||||
}
|
||||
|
||||
// Eventually is used to make asynchronous assertions. See documentation for Eventually.
|
||||
func (globalFailHandlerGomega) Eventually(actual interface{}, extra ...interface{}) AsyncAssertion {
|
||||
return Eventually(actual, extra...)
|
||||
}
|
||||
|
||||
// Consistently is used to make asynchronous assertions. See documentation for Consistently.
|
||||
func (globalFailHandlerGomega) Consistently(actual interface{}, extra ...interface{}) AsyncAssertion {
|
||||
return Consistently(actual, extra...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,6 +390,16 @@ func Panic() types.GomegaMatcher {
|
|||
return &matchers.PanicMatcher{}
|
||||
}
|
||||
|
||||
//PanicWith succeeds if actual is a function that, when invoked, panics with a specific value.
|
||||
//Actual must be a function that takes no arguments and returns no results.
|
||||
//
|
||||
//By default PanicWith uses Equal() to perform the match, however a
|
||||
//matcher can be passed in instead:
|
||||
// Expect(fn).Should(PanicWith(MatchRegexp(`.+Foo$`)))
|
||||
func PanicWith(expected interface{}) types.GomegaMatcher {
|
||||
return &matchers.PanicMatcher{Expected: expected}
|
||||
}
|
||||
|
||||
//BeAnExistingFile succeeds if a file exists.
|
||||
//Actual must be a string representing the abs path to the file being checked.
|
||||
func BeAnExistingFile() types.GomegaMatcher {
|
||||
|
|
@ -408,6 +418,15 @@ func BeADirectory() types.GomegaMatcher {
|
|||
return &matchers.BeADirectoryMatcher{}
|
||||
}
|
||||
|
||||
//HaveHTTPStatus succeeds if the Status or StatusCode field of an HTTP response matches.
|
||||
//Actual must be either a *http.Response or *httptest.ResponseRecorder.
|
||||
//Expected must be either an int or a string.
|
||||
// Expect(resp).Should(HaveHTTPStatus(http.StatusOK)) // asserts that resp.StatusCode == 200
|
||||
// Expect(resp).Should(HaveHTTPStatus("404 Not Found")) // asserts that resp.Status == "404 Not Found"
|
||||
func HaveHTTPStatus(expected interface{}) types.GomegaMatcher {
|
||||
return &matchers.HaveHTTPStatusMatcher{Expected: expected}
|
||||
}
|
||||
|
||||
//And succeeds only if all of the given matchers succeed.
|
||||
//The matchers are tried in order, and will fail-fast if one doesn't succeed.
|
||||
// Expect("hi").To(And(HaveLen(2), Equal("hi"))
|
||||
|
|
|
|||
42
common/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go
generated
vendored
Normal file
42
common/vendor/github.com/onsi/gomega/matchers/have_http_status_matcher.go
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
package matchers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
type HaveHTTPStatusMatcher struct {
|
||||
Expected interface{}
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
var resp *http.Response
|
||||
switch a := actual.(type) {
|
||||
case *http.Response:
|
||||
resp = a
|
||||
case *httptest.ResponseRecorder:
|
||||
resp = a.Result()
|
||||
default:
|
||||
return false, fmt.Errorf("HaveHTTPStatus matcher expects *http.Response or *httptest.ResponseRecorder. Got:\n%s", format.Object(actual, 1))
|
||||
}
|
||||
|
||||
switch e := matcher.Expected.(type) {
|
||||
case int:
|
||||
return resp.StatusCode == e, nil
|
||||
case string:
|
||||
return resp.Status == e, nil
|
||||
}
|
||||
|
||||
return false, fmt.Errorf("HaveHTTPStatus matcher must be passed an int or a string. Got:\n%s", format.Object(matcher.Expected, 1))
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "to have HTTP status", matcher.Expected)
|
||||
}
|
||||
|
||||
func (matcher *HaveHTTPStatusMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
return format.Message(actual, "not to have HTTP status", matcher.Expected)
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type PanicMatcher struct {
|
||||
Expected interface{}
|
||||
object interface{}
|
||||
}
|
||||
|
||||
|
|
@ -28,7 +29,21 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error)
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
matcher.object = e
|
||||
|
||||
if matcher.Expected == nil {
|
||||
success = true
|
||||
return
|
||||
}
|
||||
|
||||
valueMatcher, valueIsMatcher := matcher.Expected.(omegaMatcher)
|
||||
if !valueIsMatcher {
|
||||
valueMatcher = &EqualMatcher{Expected: matcher.Expected}
|
||||
}
|
||||
|
||||
success, err = valueMatcher.Match(e)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("PanicMatcher's value matcher failed with:\n%s%s", format.Indent, err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
@ -38,9 +53,62 @@ func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error)
|
|||
}
|
||||
|
||||
func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
if matcher.Expected == nil {
|
||||
// We wanted any panic to occur, but none did.
|
||||
return format.Message(actual, "to panic")
|
||||
}
|
||||
|
||||
if matcher.object == nil {
|
||||
// We wanted a panic with a specific value to occur, but none did.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(actual, "to panic with a value matching", matcher.Expected)
|
||||
default:
|
||||
return format.Message(actual, "to panic with", matcher.Expected)
|
||||
}
|
||||
}
|
||||
|
||||
// We got a panic, but the value isn't what we expected.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"to panic with a value matching\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
default:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"to panic with\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
if matcher.Expected == nil {
|
||||
// We didn't want any panic to occur, but one did.
|
||||
return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
|
||||
}
|
||||
|
||||
// We wanted a to ensure a panic with a specific value did not occur, but it did.
|
||||
switch matcher.Expected.(type) {
|
||||
case omegaMatcher:
|
||||
return format.Message(
|
||||
actual,
|
||||
fmt.Sprintf(
|
||||
"not to panic with a value matching\n%s\nbut panicked with\n%s",
|
||||
format.Object(matcher.Expected, 1),
|
||||
format.Object(matcher.object, 1),
|
||||
),
|
||||
)
|
||||
default:
|
||||
return format.Message(actual, "not to panic with", matcher.Expected)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ github.com/onsi/ginkgo/reporters/stenographer
|
|||
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
|
||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
|
||||
github.com/onsi/ginkgo/types
|
||||
# github.com/onsi/gomega v1.9.0
|
||||
# github.com/onsi/gomega v1.10.0
|
||||
github.com/onsi/gomega
|
||||
github.com/onsi/gomega/format
|
||||
github.com/onsi/gomega/internal/assertion
|
||||
|
|
|
|||
Loading…
Reference in New Issue