
This commit removes the configuration files for Godeps as well as the vendored dependencies, replacing them with go modules, Go's built-in dependency management system. This dramatically slims down the size of the repo (from 25M to 324K, discounting the .git directory) and greatly speeds up cloning times. This will also provide mechanisms for managing versions of any auxiliary tools (e.g. linters), creating a reproducible environment for developers and CI/CD efforts. This also modifies the Makefile to take into account that the repo no longer needs to be cloned into the GOPATH. Change-Id: I2213792cc3ce81831d5b835f2252ca6f137e0086
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package container
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
|
|
"opendev.org/airship/kubernetes-entrypoint/entrypoint"
|
|
"opendev.org/airship/kubernetes-entrypoint/mocks"
|
|
)
|
|
|
|
const (
|
|
podEnvVariableName = "POD_NAME"
|
|
)
|
|
|
|
var testEntrypoint entrypoint.EntrypointInterface
|
|
|
|
var _ = Describe("Container", func() {
|
|
|
|
BeforeEach(func() {
|
|
err := os.Setenv(podEnvVariableName, mocks.PodEnvVariableValue)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
testEntrypoint = mocks.NewEntrypoint()
|
|
})
|
|
|
|
It("checks the name of a newly created container", func() {
|
|
container := NewContainer(mocks.MockContainerName)
|
|
|
|
Expect(container.name).To(Equal(mocks.MockContainerName))
|
|
})
|
|
|
|
It(fmt.Sprintf("checks container resolution failure with %s not set", podEnvVariableName), func() {
|
|
os.Unsetenv(podEnvVariableName)
|
|
container := NewContainer(mocks.MockContainerName)
|
|
|
|
isResolved, err := container.IsResolved(testEntrypoint)
|
|
Expect(isResolved).To(Equal(false))
|
|
Expect(err).To(HaveOccurred())
|
|
Expect(err.Error()).To(Equal(PodNameNotSetError))
|
|
})
|
|
|
|
It("checks resolution of a succeeding container", func() {
|
|
container := NewContainer(mocks.MockContainerName)
|
|
|
|
isResolved, err := container.IsResolved(testEntrypoint)
|
|
|
|
Expect(isResolved).To(Equal(true))
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
It(fmt.Sprintf("fails to resolve a mocked container for a given %s value", podEnvVariableName), func() {
|
|
err := os.Setenv(podEnvVariableName, "INVALID_POD_LIST_VALUE")
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
container := NewContainer(mocks.PodNotPresent)
|
|
Expect(container).NotTo(Equal(nil))
|
|
|
|
var isResolved bool
|
|
isResolved, err = container.IsResolved(testEntrypoint)
|
|
Expect(isResolved).To(Equal(false))
|
|
Expect(err).To(BeNil())
|
|
})
|
|
})
|