-
Notifications
You must be signed in to change notification settings - Fork 53
test(ws): Notebooks 2.0 // Backend // Add tests #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: notebooks-v2
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
78d7e48
to
b8ab4b0
Compare
workspaces/backend/go.mod
Outdated
@@ -9,6 +9,7 @@ require ( | |||
github.com/kubeflow/notebooks/workspaces/controller v0.0.0 | |||
github.com/onsi/ginkgo/v2 v2.19.0 | |||
github.com/onsi/gomega v1.33.1 | |||
github.com/stretchr/testify v1.9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually have a dependency on testify
? I don't see it referenced anywhere...
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("NewRequestAuthenticator", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
admittedly could be viewed as "overkill" here - but seems like we could write a generic helper function to run the authenticate tests
By simply providing user
+ groups
+ prefx
as input to said generic function - it could do the invoking and also dynamically make the right assertions based on input being defined/empty
Describe("ValidateFieldIsDNS1123Subdomain", func() { | ||
path := field.NewPath("metadata", "name") | ||
|
||
DescribeTable("should validate DNS1123 subdomain", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice use of DescribeTable
💯
BeforeEach(func() { | ||
// Set up once for all tests | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove this empty BeforeEach
if there is no setup required
ws1 = &kubefloworgv1beta1.Workspace{ObjectMeta: metav1.ObjectMeta{Name: "ws1", Namespace: ns1}, Spec: kubefloworgv1beta1.WorkspaceSpec{Kind: "kind1"}} | ||
ws2 = &kubefloworgv1beta1.Workspace{ObjectMeta: metav1.ObjectMeta{Name: "ws2", Namespace: ns1}, Spec: kubefloworgv1beta1.WorkspaceSpec{Kind: "kind-nonexistent"}} | ||
ws3 = &kubefloworgv1beta1.Workspace{ObjectMeta: metav1.ObjectMeta{Name: "ws3", Namespace: ns2}, Spec: kubefloworgv1beta1.WorkspaceSpec{Kind: "kind1"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I wholly appreciate what this test setup is trying to do - I feel a little uneasy about constructing this scenario in a way that is literally impossible to encounter in the "real world"...
i.e. if we are declaring a WorkspaceSpec
- it feels weird/wrong to me to set the Kind
to some value other than Workspace
Don't feel strongly about the change - but I wonder if we could simply include some non-Workspace
objects in the initObjs
parameter that then more closely simulates how this works in reality...
Expect(wss).To(BeEmpty()) | ||
}) | ||
|
||
It("returns all workspaces in the cluster", func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given we declared ws2
as such:
ws2 = &kubefloworgv1beta1.Workspace{ObjectMeta: metav1.ObjectMeta{Name: "ws2", Namespace: ns1}, Spec: kubefloworgv1beta1.WorkspaceSpec{Kind: "kind-nonexistent"}}
It seems odd to me (at face value) we would then expect this result to appear when getting all workspaces 🤔
I'm probably reading the code too literally - but worry it could be a head-scratcher in the future...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was getting confused on kind
vs. spec.kind
- which @yehudit1987 kinda clearly up for me...
This comment can be ignored.
Signed-off-by: Yehudit Kerido <[email protected]>
/ok-to-test |
/lgtm Great (and much needed) foundation for getting tests added in critical areas 💯
|
This PR solves partially issue #381