Skip to content

Commit 48a762b

Browse files
Update diff test
1 parent 2d1dbda commit 48a762b

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

cmd/kubeapply/subcmd/diff_test.go

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ package subcmd
22

33
import (
44
"context"
5+
"fmt"
6+
"io/ioutil"
7+
"os"
58
"path/filepath"
69
"testing"
10+
"time"
711

812
"github.com/segmentio/kubeapply/pkg/util"
913
"github.com/stretchr/testify/require"
@@ -16,13 +20,33 @@ func TestDiff(t *testing.T) {
1620

1721
ctx := context.Background()
1822

19-
testClusterDir := "testdata/clusters/basic"
23+
namespace := fmt.Sprintf("test-diff-%d", time.Now().UnixNano()/1000)
24+
util.CreateNamespace(ctx, t, namespace, kubeConfigTestPath)
2025

26+
tempDir, err := ioutil.TempDir("", "diff")
27+
require.Nil(t, err)
28+
defer os.RemoveAll(tempDir)
29+
30+
clusterDir := filepath.Join(tempDir, "cluster")
31+
require.Nil(t, err)
32+
33+
err = util.RecursiveCopy("testdata/clusters/apply-test", clusterDir)
34+
require.Nil(t, err)
35+
replaceNamespace(t, filepath.Join(clusterDir, "expanded"), namespace)
36+
37+
// Full outputs
2138
diffFlagValues.kubeConfig = kubeConfigTestPath
39+
err = diffClusterPath(
40+
ctx,
41+
filepath.Join(clusterDir, "cluster.yaml"),
42+
)
43+
require.Nil(t, err)
2244

23-
err := diffClusterPath(
45+
// Simple outputs
46+
diffFlagValues.simpleOutput = true
47+
err = diffClusterPath(
2448
ctx,
25-
filepath.Join(testClusterDir, "cluster.yaml"),
49+
filepath.Join(clusterDir, "cluster.yaml"),
2650
)
2751
require.Nil(t, err)
2852
}

data/data.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)