Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
jlandowner committed Aug 28, 2023
1 parent 64e3ba1 commit fd0a7c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
10 changes: 8 additions & 2 deletions internal/dashboard/__snapshots__/workspace_handler_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,10 @@ SnapShot = """
\"metadata\": {
\"name\": \"ws1\",
\"namespace\": \"cosmo-user-admin-user\",
\"creationTimestamp\": null
\"creationTimestamp\": null,
\"annotations\": {
\"workspace.cosmo-workspace.github.io/last-stopped-at\": \"MASKED\"
}
},
\"spec\": {
\"template\": {
Expand Down Expand Up @@ -643,7 +646,10 @@ SnapShot = """
\"metadata\": {
\"name\": \"ws1\",
\"namespace\": \"cosmo-user-normal-user\",
\"creationTimestamp\": null
\"creationTimestamp\": null,
\"annotations\": {
\"workspace.cosmo-workspace.github.io/last-started-at\": \"MASKED\"
}
},
\"spec\": {
\"template\": {
Expand Down
29 changes: 21 additions & 8 deletions pkg/snap/object_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ func UserSnapshot(in *cosmov1alpha1.User) *cosmov1alpha1.User {
obj.Status.Addons[i] = v
}
sort.Slice(obj.Status.Addons, func(i, j int) bool {
return obj.Status.Addons[i].Kind < obj.Status.Addons[j].Kind
})
sort.Slice(obj.Status.Addons, func(i, j int) bool {
return obj.Status.Addons[i].Name < obj.Status.Addons[j].Name
x, y := obj.Status.Addons[i], obj.Status.Addons[j]
if x.Kind != y.Kind {
return x.Kind < y.Kind
} else {
return x.Name < y.Name
}
})

return obj
Expand All @@ -47,10 +49,12 @@ func InstanceSnapshot(in cosmov1alpha1.InstanceObject) cosmov1alpha1.InstanceObj
obj.GetStatus().LastApplied[i] = v
}
sort.Slice(obj.GetStatus().LastApplied, func(i, j int) bool {
return obj.GetStatus().LastApplied[i].Kind < obj.GetStatus().LastApplied[j].Kind
})
sort.Slice(obj.GetStatus().LastApplied, func(i, j int) bool {
return obj.GetStatus().LastApplied[i].Name < obj.GetStatus().LastApplied[j].Name
x, y := obj.GetStatus().LastApplied[i], obj.GetStatus().LastApplied[j]
if x.Kind != y.Kind {
return x.Kind < y.Kind
} else {
return x.Name < y.Name
}
})
obj.GetStatus().TemplateResourceVersion = ""

Expand Down Expand Up @@ -93,4 +97,13 @@ func RemoveDynamicFields(o client.Object) {
ownerRefs[i] = v
}
o.SetOwnerReferences(ownerRefs)

if ann := o.GetAnnotations(); ann != nil {
if _, ok := ann[cosmov1alpha1.WorkspaceAnnKeyLastStartedAt]; ok {
ann[cosmov1alpha1.WorkspaceAnnKeyLastStartedAt] = "MASKED"
}
if _, ok := ann[cosmov1alpha1.WorkspaceAnnKeyLastStoppedAt]; ok {
ann[cosmov1alpha1.WorkspaceAnnKeyLastStoppedAt] = "MASKED"
}
}
}

0 comments on commit fd0a7c4

Please sign in to comment.