Skip to content

Commit

Permalink
tests: add expect no changes step after updating yaml manifests
Browse files Browse the repository at this point in the history
  • Loading branch information
rquitales committed May 28, 2024
1 parent c98b399 commit a671a4d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/sdk/nodejs/nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ func TestReadonlyMetadata(t *testing.T) {

func TestRenderYAML(t *testing.T) {
// Create a temporary directory to hold rendered YAML manifests.
dir, err := ioutil.TempDir("", "")
dir, err := os.MkdirTemp("", "render-yaml-test")
assert.NoError(t, err)
defer os.RemoveAll(dir)

Expand Down Expand Up @@ -1169,6 +1169,19 @@ func TestRenderYAML(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, len(files), 2)
},
EditDirs: []integration.EditDir{
{
// Change some fields.
Dir: filepath.Join("render-yaml", "step2"),
Additive: true,
},
{
// Ensure updates do not cause a spurrious diff when re-running `pulumi up`.
Dir: filepath.Join("render-yaml", "step2"),
Additive: true,
ExpectNoChanges: true,
},
},
})

integration.ProgramTest(t, &test)
Expand Down
41 changes: 41 additions & 0 deletions tests/sdk/nodejs/render-yaml/step2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2016-2022, Pulumi Corporation.
//
// 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.

import * as k8s from "@pulumi/kubernetes";
import * as pulumi from "@pulumi/pulumi";

let config = new pulumi.Config();
let renderDir: string = config.require("renderDir");

const provider = new k8s.Provider("render-yaml", {
renderYamlToDirectory: renderDir,
});

const appLabels = {app: "nginx"};
const deployment = new k8s.apps.v1.Deployment("nginx", {
spec: {
selector: {matchLabels: appLabels},
replicas: 1,
template: {
metadata: {labels: appLabels},
spec: {containers: [{name: "nginx-fake", image: "nginx-fake", ports: [{containerPort: 80}]}]}
}
}
}, {provider});
const service = new k8s.core.v1.Service("nginx", {
spec: {
ports: [{port: 8080, protocol: "TCP"}],
selector: deployment.metadata.labels,
}
}, {provider});

0 comments on commit a671a4d

Please sign in to comment.