Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dry-run to dry-run=client #143

Merged
merged 2 commits into from
Apr 1, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
update tests
  • Loading branch information
tonglil committed Apr 1, 2021
commit aa652e790d0adc9d312f1df0a9009e016a5ce4ef
30 changes: 15 additions & 15 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ func TestTemplateData(t *testing.T) {
"zone": "us-east1-b",
"cluster": "cluster-0",
"namespace": "",
"key0": "val0",
"key1": "hello $USER",
"SECRET_TEST": "test_val",
"key0": "val0",
"key1": "hello $USER",
"SECRET_TEST": "test_val",
}, secretsData)
assert.Equal(t, map[string]string{"SECRET_TEST": "VALUE REDACTED"}, secretsDataRedacted)
assert.NoError(t, err)
Expand Down Expand Up @@ -314,9 +314,9 @@ func TestTemplateDataExpandingVars(t *testing.T) {
"zone": "us-east1-b",
"cluster": "cluster-0",
"namespace": "",
"key0": "val0",
"key1": "hello drone-user",
"SECRET_TEST": "test_val",
"key0": "val0",
"key1": "hello drone-user",
"SECRET_TEST": "test_val",
}, secretsData)
assert.Equal(t, map[string]string{"SECRET_TEST": "VALUE REDACTED"}, secretsDataRedacted)
assert.NoError(t, err)
Expand Down Expand Up @@ -350,8 +350,8 @@ func TestRenderTemplates(t *testing.T) {
"key0": "val0",
}
secretsData := map[string]interface{}{
"COMMIT": "e0f21b90a",
"key0": "val0",
"COMMIT": "e0f21b90a",
"key0": "val0",
"SECRET_TEST": "test_sec_val",
}

Expand Down Expand Up @@ -485,7 +485,7 @@ func TestSetNamespace(t *testing.T) {

testRunner = new(MockedRunner)
testRunner.On("Run", []string{"kubectl", "config", "set-context", "gke_test-project_us-east1-b_cluster-0", "--namespace", "feature-1892-test-ns"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/tmp/namespace.json"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/tmp/namespace.json"}).Return(nil)
err = setNamespace(c, "test-project", testRunner)
testRunner.AssertExpectations(t)
assert.NoError(t, err)
Expand All @@ -505,8 +505,8 @@ func TestApplyManifests(t *testing.T) {
}

testRunner := new(MockedRunner)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/path/to/secret-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/path/to/secret-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--filename", "/path/to/secret-tamplate"}).Return(nil)
err := applyManifests(c, manifestPaths, testRunner, testRunner)
Expand All @@ -519,7 +519,7 @@ func TestApplyManifests(t *testing.T) {
}

testRunner = new(MockedRunner)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--filename", "/path/to/kube-tamplate"}).Return(nil)
err = applyManifests(c, manifestPaths, testRunner, testRunner)
testRunner.AssertExpectations(t)
Expand All @@ -538,8 +538,8 @@ func TestApplyManifests(t *testing.T) {
}

testRunner = new(MockedRunner)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run", "--filename", "/path/to/secret-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/path/to/kube-tamplate"}).Return(nil)
testRunner.On("Run", []string{"kubectl", "apply", "--record", "--dry-run=client", "--filename", "/path/to/secret-tamplate"}).Return(nil)
err = applyManifests(c, manifestPaths, testRunner, testRunner)
testRunner.AssertExpectations(t)
assert.NoError(t, err)
Expand Down Expand Up @@ -584,7 +584,7 @@ func TestApplyArgs(t *testing.T) {
assert.Equal(t, []string{"apply", "--record", "--filename", "/path/to/file/1"}, args)

args = applyArgs(true, "/path/to/file/2")
assert.Equal(t, []string{"apply", "--record", "--dry-run", "--filename", "/path/to/file/2"}, args)
assert.Equal(t, []string{"apply", "--record", "--dry-run=client", "--filename", "/path/to/file/2"}, args)
}

func TestPrintTrimmedError(t *testing.T) {
Expand Down