@@ -197,17 +197,17 @@ var _ = Describe("Workspaces Handler", func() {
197197
198198 By ("ensuring the response contains the expected Workspaces" )
199199 Expect (response .Data ).To (ConsistOf (
200- models .NewWorkspaceModelFromWorkspace (workspace1 , workspaceKind ),
201- models .NewWorkspaceModelFromWorkspace (workspace2 , workspaceKind ),
202- models .NewWorkspaceModelFromWorkspace (workspace3 , workspaceKind ),
200+ models .NewWorkspaceListItemFromWorkspace (workspace1 , workspaceKind ),
201+ models .NewWorkspaceListItemFromWorkspace (workspace2 , workspaceKind ),
202+ models .NewWorkspaceListItemFromWorkspace (workspace3 , workspaceKind ),
203203 ))
204204
205- By ("ensuring the response can be marshaled to JSON and back to []Workspace " )
205+ By ("ensuring the response can be marshaled to JSON and back to []WorkspaceListItem " )
206206 dataJSON , err := json .Marshal (response .Data )
207207 Expect (err ).NotTo (HaveOccurred (), "failed to marshal data to JSON" )
208- var dataObject []models.Workspace
208+ var dataObject []models.WorkspaceListItem
209209 err = json .Unmarshal (dataJSON , & dataObject )
210- Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to []Workspace " )
210+ Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to []WorkspaceListItem " )
211211 })
212212
213213 It ("should retrieve Workspaces from Namespace 1 successfully" , func () {
@@ -252,16 +252,16 @@ var _ = Describe("Workspaces Handler", func() {
252252
253253 By ("ensuring the response contains the expected Workspaces" )
254254 Expect (response .Data ).To (ConsistOf (
255- models .NewWorkspaceModelFromWorkspace (workspace1 , workspaceKind ),
256- models .NewWorkspaceModelFromWorkspace (workspace2 , workspaceKind ),
255+ models .NewWorkspaceListItemFromWorkspace (workspace1 , workspaceKind ),
256+ models .NewWorkspaceListItemFromWorkspace (workspace2 , workspaceKind ),
257257 ))
258258
259- By ("ensuring the response can be marshaled to JSON and back to []Workspace " )
259+ By ("ensuring the response can be marshaled to JSON and back to []WorkspaceListItem " )
260260 dataJSON , err := json .Marshal (response .Data )
261261 Expect (err ).NotTo (HaveOccurred (), "failed to marshal data to JSON" )
262- var dataObject []models.Workspace
262+ var dataObject []models.WorkspaceListItem
263263 err = json .Unmarshal (dataJSON , & dataObject )
264- Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to []Workspace " )
264+ Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to []WorkspaceListItem " )
265265 })
266266
267267 It ("should retrieve a single Workspace successfully" , func () {
@@ -296,23 +296,24 @@ var _ = Describe("Workspaces Handler", func() {
296296 err = json .Unmarshal (body , & response )
297297 Expect (err ).NotTo (HaveOccurred ())
298298
299- By ("getting the WorkspaceKind from the Kubernetes API" )
300- workspaceKind := & kubefloworgv1beta1.WorkspaceKind {}
301- Expect (k8sClient .Get (ctx , workspaceKindKey , workspaceKind )).To (Succeed ())
302-
303299 By ("getting the Workspace from the Kubernetes API" )
304300 workspace := & kubefloworgv1beta1.Workspace {}
305301 Expect (k8sClient .Get (ctx , workspaceKey1 , workspace )).To (Succeed ())
306302
307- By ("ensuring the response matches the expected Workspace" )
308- Expect (response .Data ).To (BeComparableTo (models .NewWorkspaceModelFromWorkspace (workspace , workspaceKind )))
303+ By ("ensuring the response matches the expected WorkspaceUpdate" )
304+ expectedWorkspaceUpdate := models .NewWorkspaceUpdateModelFromWorkspace (workspace )
305+ // Normalize Secrets to nil if empty to match JSON unmarshaling behavior (omitempty causes empty slices to become nil)
306+ if len (expectedWorkspaceUpdate .PodTemplate .Volumes .Secrets ) == 0 {
307+ expectedWorkspaceUpdate .PodTemplate .Volumes .Secrets = nil
308+ }
309+ Expect (response .Data ).To (BeComparableTo (expectedWorkspaceUpdate ))
309310
310- By ("ensuring the response can be marshaled to JSON and back to Workspace " )
311+ By ("ensuring the response can be marshaled to JSON and back to WorkspaceUpdate " )
311312 dataJSON , err := json .Marshal (response .Data )
312313 Expect (err ).NotTo (HaveOccurred (), "failed to marshal data to JSON" )
313- var dataObject models.Workspace
314+ var dataObject models.WorkspaceUpdate
314315 err = json .Unmarshal (dataJSON , & dataObject )
315- Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to Workspace " )
316+ Expect (err ).NotTo (HaveOccurred (), "failed to unmarshal JSON to WorkspaceUpdate " )
316317 })
317318 })
318319
@@ -463,7 +464,7 @@ var _ = Describe("Workspaces Handler", func() {
463464 Expect (k8sClient .Get (ctx , workspaceInvalidImageConfigKey , workspaceInvalidImageConfig )).To (Succeed ())
464465
465466 By ("ensuring the model for Workspace with missing WorkspaceKind is as expected" )
466- workspaceMissingWskModel := models .NewWorkspaceModelFromWorkspace (workspaceMissingWsk , nil )
467+ workspaceMissingWskModel := models .NewWorkspaceListItemFromWorkspace (workspaceMissingWsk , nil )
467468 Expect (workspaceMissingWskModel .WorkspaceKind .Missing ).To (BeTrue ())
468469 Expect (workspaceMissingWskModel .PodTemplate .Volumes .Home .MountPath ).To (Equal (models .UnknownHomeMountPath ))
469470 Expect (workspaceMissingWskModel .PodTemplate .Options .PodConfig .Current .DisplayName ).To (Equal (models .UnknownPodConfig ))
@@ -472,12 +473,12 @@ var _ = Describe("Workspaces Handler", func() {
472473 Expect (workspaceMissingWskModel .PodTemplate .Options .ImageConfig .Current .Description ).To (Equal (models .UnknownImageConfig ))
473474
474475 By ("ensuring the model for Workspace with invalid PodConfig is as expected" )
475- workspaceInvalidPodConfigModel := models .NewWorkspaceModelFromWorkspace (workspaceInvalidPodConfig , workspaceKind )
476+ workspaceInvalidPodConfigModel := models .NewWorkspaceListItemFromWorkspace (workspaceInvalidPodConfig , workspaceKind )
476477 Expect (workspaceInvalidPodConfigModel .PodTemplate .Options .PodConfig .Current .DisplayName ).To (Equal (models .UnknownPodConfig ))
477478 Expect (workspaceInvalidPodConfigModel .PodTemplate .Options .PodConfig .Current .Description ).To (Equal (models .UnknownPodConfig ))
478479
479480 By ("ensuring the model for Workspace with invalid ImageConfig is as expected" )
480- workspaceInvalidImageConfigModel := models .NewWorkspaceModelFromWorkspace (workspaceInvalidImageConfig , workspaceKind )
481+ workspaceInvalidImageConfigModel := models .NewWorkspaceListItemFromWorkspace (workspaceInvalidImageConfig , workspaceKind )
481482 Expect (workspaceInvalidImageConfigModel .PodTemplate .Options .ImageConfig .Current .DisplayName ).To (Equal (models .UnknownImageConfig ))
482483 Expect (workspaceInvalidImageConfigModel .PodTemplate .Options .ImageConfig .Current .Description ).To (Equal (models .UnknownImageConfig ))
483484
@@ -489,7 +490,7 @@ var _ = Describe("Workspaces Handler", func() {
489490 ))
490491 })
491492
492- It ("should retrieve a single invalid Workspace successfully" , func () {
493+ It ("should retrieve a single Workspace successfully" , func () {
493494 By ("creating the HTTP request" )
494495 path := strings .Replace (WorkspacesByNamePath , ":" + NamespacePathParam , namespaceName1 , 1 )
495496 path = strings .Replace (path , ":" + ResourceNamePathParam , workspaceMissingWskName , 1 )
@@ -525,8 +526,12 @@ var _ = Describe("Workspaces Handler", func() {
525526 workspaceMissingWsk := & kubefloworgv1beta1.Workspace {}
526527 Expect (k8sClient .Get (ctx , workspaceMissingWskKey , workspaceMissingWsk )).To (Succeed ())
527528
528- By ("ensuring the response matches the expected Workspace" )
529- workspaceMissingWskModel := models .NewWorkspaceModelFromWorkspace (workspaceMissingWsk , nil )
529+ By ("ensuring the response matches the expected WorkspaceUpdate" )
530+ workspaceMissingWskModel := models .NewWorkspaceUpdateModelFromWorkspace (workspaceMissingWsk )
531+ // Normalize Secrets to nil if empty to match JSON unmarshaling behavior (omitempty causes empty slices to become nil)
532+ if len (workspaceMissingWskModel .PodTemplate .Volumes .Secrets ) == 0 {
533+ workspaceMissingWskModel .PodTemplate .Volumes .Secrets = nil
534+ }
530535 Expect (response .Data ).To (BeComparableTo (workspaceMissingWskModel ))
531536 })
532537 })
0 commit comments