Skip to content

Commit

Permalink
chore: Add test for source updated
Browse files Browse the repository at this point in the history
Signed-off-by: Diego Alfonso <[email protected]>
  • Loading branch information
odinnordico committed May 25, 2023
1 parent e3d753b commit fd3b47a
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/commands/testdata/workload-lsp-subPath.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 VMware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: carto.run/v1alpha1
kind: Workload
metadata:
annotations:
local-source-proxy.apps.tanzu.vmware.com: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
labels:
apps.tanzu.vmware.com/workload-type: web
name: my-workload
namespace: default
spec:
params:
- name: annotations
value:
autoscaling.knative.dev/minScale: "2"
source:
image: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
subPath: new-subpath
70 changes: 70 additions & 0 deletions pkg/commands/workload_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8909,6 +8909,76 @@ To get status: "tanzu apps workload get my-workload"
}
},
},
{
Name: "update from local source using lsp changing subpath",
Skip: runtm.GOOS == "windows",
Args: []string{workloadName, flags.LocalPathFlagName, localSource, flags.FilePathFlagName, "./testdata/workload-lsp-subPath.yaml", flags.YesFlagName},
GivenObjects: []client.Object{
parent.
MetadataDie(func(d *diemetav1.ObjectMetaDie) {
d.Annotations(map[string]string{apis.LocalSourceProxyAnnotationName: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69"})
d.Labels(map[string]string{apis.WorkloadTypeLabelName: "web"})
}).SpecDie(func(d *diecartov1alpha1.WorkloadSpecDie) {
d.Source(&cartov1alpha1.Source{
Image: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
Subpath: "old-subpath",
})
}),
},
KubeConfigTransport: clitesting.NewFakeTransportFromResponse(respCreator(http.StatusOK, `{"statuscode": "200", "message": "any ignored message"}`, myWorkloadHeader)),
ExpectUpdates: []client.Object{
&cartov1alpha1.Workload{
ObjectMeta: metav1.ObjectMeta{
Namespace: defaultNamespace,
Name: workloadName,
Labels: map[string]string{
apis.WorkloadTypeLabelName: "web",
},
Annotations: map[string]string{
"local-source-proxy.apps.tanzu.vmware.com": ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
},
},
Spec: cartov1alpha1.WorkloadSpec{
Source: &cartov1alpha1.Source{
Image: ":default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69",
Subpath: "new-subpath",
},
Params: []cartov1alpha1.Param{
{
Name: "annotations",
Value: apiextensionsv1.JSON{Raw: []byte(`{"autoscaling.knative.dev/minScale":"2"}`)},
},
},
},
},
},
ExpectOutput: fmt.Sprintf(`
❗ WARNING: Configuration file update strategy is changing. By default, provided configuration files will replace rather than merge existing configuration. The change will take place in the January 2024 TAP release (use "--update-strategy" to control strategy explicitly).
Publishing source in "%s" to "local-source-proxy.tap-local-source-system.svc.cluster.local/source:default-my-workload"...
No source code is changed
🔎 Update workload:
...
8, 8 | apps.tanzu.vmware.com/workload-type: web
9, 9 | name: my-workload
10, 10 | namespace: default
11, 11 |spec:
12 + | params:
13 + | - name: annotations
14 + | value:
15 + | autoscaling.knative.dev/minScale: "2"
12, 16 | source:
13, 17 | image: :default-my-workload@sha256:978be33a7f0cbe89bf48fbb438846047a28e1298d6d10d0de2d64bdc102a9e69
14 - | subPath: old-subpath
18 + | subPath: new-subpath
👍 Updated workload "my-workload"
To see logs: "tanzu apps workload tail my-workload --timestamp --since 1h"
To get status: "tanzu apps workload get my-workload"
`, localSource),
},
}

table.Run(t, scheme, func(ctx context.Context, c *cli.Config) *cobra.Command {
Expand Down

0 comments on commit fd3b47a

Please sign in to comment.