-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
78 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestApplyEnvironment(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
os.Chdir(tmpDir) | ||
runCmd(t, "tk", "init") | ||
runCmd(t, "tk", "env", "set", "environments/default", "--server=https://kubernetes:6443") | ||
content := ` | ||
{ | ||
config: { | ||
apiVersion: "v1", | ||
kind: "ConfigMap", | ||
metadata : { | ||
name: "demo", | ||
}, | ||
data: {}, | ||
}, | ||
} | ||
` | ||
require.NoError(t, os.WriteFile("environments/default/main.jsonnet", []byte(content), 0600)) | ||
runCmd(t, "tk", "apply", "environments/default", "--auto-approve", "always") | ||
// Now that the configmap should be there, let's verify it | ||
runCmd(t, "kubectl", "--namespace", "default", "get", "configmap", "demo") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestExportEnvironment(t *testing.T) { | ||
tmpDir := t.TempDir() | ||
os.Chdir(tmpDir) | ||
runCmd(t, "tk", "init") | ||
runCmd(t, "tk", "env", "set", "environments/default", "--server=https://kubernetes:6443") | ||
content := ` | ||
{ | ||
config: { | ||
apiVersion: "v1", | ||
kind: "ConfigMap", | ||
metadata : { | ||
name: "demo", | ||
}, | ||
data: {}, | ||
}, | ||
} | ||
` | ||
require.NoError(t, os.WriteFile("environments/default/main.jsonnet", []byte(content), 0600)) | ||
runCmd(t, "tk", "export", "export", "environments/default") | ||
require.FileExists(t, "export/v1.ConfigMap-demo.yaml") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func runCmd(t *testing.T, cmd string, args ...string) { | ||
c := exec.Command(cmd, args...) | ||
c.Stdout = os.Stdout | ||
c.Stderr = os.Stderr | ||
err := c.Run() | ||
require.NoError(t, err) | ||
} |