Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions cmd/kubeapply/subcmd/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ package subcmd

import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"

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

ctx := context.Background()

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

tempDir, err := ioutil.TempDir("", "diff")
require.Nil(t, err)
defer os.RemoveAll(tempDir)

clusterDir := filepath.Join(tempDir, "cluster")
require.Nil(t, err)

err = util.RecursiveCopy("testdata/clusters/apply-test", clusterDir)
require.Nil(t, err)
replaceNamespace(t, filepath.Join(clusterDir, "expanded"), namespace)

// Full outputs
diffFlagValues.kubeConfig = kubeConfigTestPath
err = diffClusterPath(
ctx,
filepath.Join(clusterDir, "cluster.yaml"),
)
require.Nil(t, err)

err := diffClusterPath(
// Simple outputs
diffFlagValues.simpleOutput = true
err = diffClusterPath(
ctx,
filepath.Join(testClusterDir, "cluster.yaml"),
filepath.Join(clusterDir, "cluster.yaml"),
)
require.Nil(t, err)
}
2 changes: 1 addition & 1 deletion data/data.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.