Skip to content

Instantly share code, notes, and snippets.

@aslakknutsen
Created February 28, 2019 16:42
Show Gist options
  • Save aslakknutsen/e1d9c807bd38a9f1bde26b7a0f1e44cf to your computer and use it in GitHub Desktop.
Save aslakknutsen/e1d9c807bd38a9f1bde26b7a0f1e44cf to your computer and use it in GitHub Desktop.
ginkgo
var objects []runtime.Object
var ctx model.SessionContext
BeforeEach(func() {
ctx = model.SessionContext{
Context: context.TODO(),
Name: "test",
Namespace: "test",
Log: logf.Log.WithName("test"),
Client: fake.NewFakeClient(objects...),
}
})
Context("locators", func() {
It("should report false on not found", func() {
//testClient.Setup([]T{T{Error: errors.NewNotFound(schema.GroupResource{Group: "core", Resource: "Deployment"}, "test")}})
ref := model.Ref{Name: "test-ref"}
Expect(k8.DeploymentLocator(ctx, &ref)).To(Equal(false))
})
It("should report false on other found", func() {
//testClient.Setup([]T{T{Error: errors.NewServerTimeout(schema.GroupResource{Group: "core", Resource: "Deployment"}, "GET", 10)}})
ref := model.Ref{Name: "test-ref"}
Expect(k8.DeploymentLocator(ctx, &ref)).To(Equal(false))
})
It("should report true on found", func() {
//testClient.Setup([]T{T{Obj: &appsv1.Deployment{}}})
ref := model.Ref{Name: "test-ref"}
Expect(k8.DeploymentLocator(ctx, &ref)).To(Equal(true))
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment