Sitelet https://github.com/apache/openwhisk-cli/commit/4b70b076cfb08e04528c9ac8d1c487d72c0f64c3
Skip to content

Commit 4b70b07

Browse files
committed
Update tests.
1 parent 9901645 commit 4b70b07

3 files changed

Lines changed: 15 additions & 64 deletions

File tree

‎tests/src/integration/command_test.go‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestShowAPIVersion(t *testing.T) {
8282
// Test case to verify the default namespace _.
8383
func TestDefaultNamespace(t *testing.T) {
8484
common.CreateFile(tmpProp)
85-
common.WriteFile(tmpProp, []string{"NAMESPACE="})
85+
common.WriteFile(tmpProp, []string{"APIHOST=xyz"})
8686

8787
os.Setenv("WSK_CONFIG_FILE", tmpProp)
8888
assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
@@ -101,7 +101,7 @@ func TestValidateDefaultProperties(t *testing.T) {
101101
os.Setenv("WSK_CONFIG_FILE", tmpProp)
102102
assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
103103

104-
stdout, err := wsk.RunCommand("property", "unset", "--auth", "--apihost", "--apiversion", "--namespace")
104+
stdout, err := wsk.RunCommand("property", "unset", "--auth", "--apihost", "--apiversion")
105105
assert.Equal(t, nil, err, "The command property unset failed to run.")
106106
outputString := string(stdout)
107107
assert.Contains(t, outputString, "ok: whisk auth unset",
@@ -110,8 +110,6 @@ func TestValidateDefaultProperties(t *testing.T) {
110110
"The output of the command does not contain \"ok: whisk API host unset\".")
111111
assert.Contains(t, outputString, "ok: whisk API version unset",
112112
"The output of the command does not contain \"ok: whisk API version unset\".")
113-
assert.Contains(t, outputString, "ok: whisk namespace unset",
114-
"The output of the command does not contain \"ok: whisk namespace unset\".")
115113

116114
stdout, err = wsk.RunCommand("property", "get", "--auth")
117115
assert.Equal(t, nil, err, "The command property get --auth failed to run.")
@@ -123,11 +121,6 @@ func TestValidateDefaultProperties(t *testing.T) {
123121
assert.Equal(t, common.PropDisplayAPIHost, common.RemoveRedundentSpaces(string(stdout)),
124122
"The output of the command does not equal to "+common.PropDisplayAPIHost)
125123

126-
stdout, err = wsk.RunCommand("property", "get", "--namespace")
127-
assert.Equal(t, nil, err, "The command property get --namespace failed to run.")
128-
assert.Equal(t, common.PropDisplayNamespace+" _", common.RemoveRedundentSpaces(string(stdout)),
129-
"The output of the command does not equal to "+common.PropDisplayNamespace+" _")
130-
131124
common.DeleteFile(tmpProp)
132125
}
133126

‎tests/src/integration/integration_test.go‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package tests
2222
import (
2323
"fmt"
2424
"os"
25-
"strings"
2625
"testing"
2726

2827
"github.com/apache/incubator-openwhisk-cli/tests/src/integration/common"
@@ -331,29 +330,23 @@ func initInvalidArgs() {
331330
var wsk *common.Wsk = common.NewWsk()
332331
var tmpProp = common.GetRepoPath() + "/wskprops.tmp"
333332

334-
// Test case to set apihost, auth, and namespace.
333+
// Test case to set apihost and auth.
335334
func TestSetAPIHostAuthNamespace(t *testing.T) {
336335
common.CreateFile(tmpProp)
337336
common.WriteFile(tmpProp, []string{})
338337

339338
os.Setenv("WSK_CONFIG_FILE", tmpProp)
340339
assert.Equal(t, os.Getenv("WSK_CONFIG_FILE"), tmpProp, "The environment variable WSK_CONFIG_FILE has not been set.")
341340

342-
namespace, _ := wsk.ListNamespaces()
343-
namespaces := strings.Split(strings.TrimSpace(string(namespace)), "\n")
344-
expectedNamespace := string(namespaces[len(namespaces)-1])
345341
fmt.Println(wsk.Wskprops.APIHost)
346342
if wsk.Wskprops.APIHost != "" && wsk.Wskprops.AuthKey != "" {
347-
stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost,
348-
"--auth", wsk.Wskprops.AuthKey, "--namespace", expectedNamespace)
343+
stdout, err := wsk.RunCommand("property", "set", "--apihost", wsk.Wskprops.APIHost, "--auth", wsk.Wskprops.AuthKey)
349344
ouputString := string(stdout)
350-
assert.Equal(t, nil, err, "The command property set --apihost --auth --namespace failed to run.")
345+
assert.Equal(t, nil, err, "The command property set --apihost --auth failed to run.")
351346
assert.Contains(t, ouputString, "ok: whisk auth set. Run 'wsk property get --auth' to see the new value.",
352-
"The output of the command property set --apihost --auth --namespace does not contain \"whisk auth set\".")
347+
"The output of the command property set --apihost --auth does not contain \"whisk auth set\".")
353348
assert.Contains(t, ouputString, "ok: whisk API host set to "+wsk.Wskprops.APIHost,
354-
"The output of the command property set --apihost --auth --namespace does not contain \"whisk API host set\".")
355-
assert.Contains(t, ouputString, "ok: whisk namespace set to "+expectedNamespace,
356-
"The output of the command property set --apihost --auth --namespace does not contain \"whisk namespace set\".")
349+
"The output of the command property set --apihost --auth does not contain \"whisk API host set\".")
357350
}
358351
common.DeleteFile(tmpProp)
359352
}

‎tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskConfigTests.scala‎

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
6464
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
6565
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
6666
val stdout = wsk
67-
.cli(Seq("property", "unset", "--auth", "--cert", "--key", "--apihost", "--apiversion", "--namespace"), env = env)
67+
.cli(Seq("property", "unset", "--auth", "--cert", "--key", "--apihost", "--apiversion"), env = env)
6868
.stdout
6969
try {
7070
stdout should include regex ("ok: whisk auth unset")
7171
stdout should include regex ("ok: client cert unset")
7272
stdout should include regex ("ok: client key unset")
7373
stdout should include regex ("ok: whisk API host unset")
7474
stdout should include regex ("ok: whisk API version unset")
75-
stdout should include regex ("ok: whisk namespace unset")
7675

7776
wsk
7877
.cli(Seq("property", "get", "--auth"), env = env)
@@ -86,9 +85,6 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
8685
wsk
8786
.cli(Seq("property", "get", "--apihost"), env = env)
8887
.stdout should include regex ("""(?i)whisk API host\s*$""") // default = empty string
89-
wsk
90-
.cli(Seq("property", "get", "--namespace"), env = env)
91-
.stdout should include regex ("""(?i)whisk namespace\s*_$""") // default = _
9288
} finally {
9389
tmpwskprops.delete()
9490
}
@@ -147,28 +143,16 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
147143
}
148144
}
149145

150-
it should "set apihost, auth, and namespace" in {
146+
it should "set apihost, auth" in {
151147
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
152148
try {
153149
val namespace = wsk.namespace.whois()
154150
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
155151
val stdout = wsk
156-
.cli(
157-
Seq(
158-
"property",
159-
"set",
160-
"-i",
161-
"--apihost",
162-
wskprops.apihost,
163-
"--auth",
164-
wskprops.authKey,
165-
"--namespace",
166-
namespace),
167-
env = env)
152+
.cli(Seq("property", "set", "-i", "--apihost", wskprops.apihost, "--auth", wskprops.authKey), env = env)
168153
.stdout
169-
stdout should include(s"ok: whisk auth set")
170154
stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
171-
stdout should include(s"ok: whisk namespace set to ${namespace}")
155+
stdout should include(s"ok: whisk auth set")
172156
} finally {
173157
tmpwskprops.delete()
174158
}
@@ -196,16 +180,13 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
196180
"--cert",
197181
wskprops.cert,
198182
"--key",
199-
wskprops.key,
200-
"--namespace",
201-
namespace),
183+
wskprops.key),
202184
env = env)
203185
.stdout
186+
stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
187+
stdout should include(s"ok: whisk auth set")
204188
stdout should include(s"ok: client cert set")
205189
stdout should include(s"ok: client key set")
206-
stdout should include(s"ok: whisk auth set")
207-
stdout should include(s"ok: whisk API host set to ${wskprops.apihost}")
208-
stdout should include(s"ok: whisk namespace set to ${namespace}")
209190
} finally {
210191
tmpwskprops.delete()
211192
}
@@ -228,9 +209,7 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
228209
"--cert",
229210
"invalid-cert.pem",
230211
"--key",
231-
"invalid-key.pem",
232-
"--namespace",
233-
namespace),
212+
"invalid-key.pem"),
234213
env = env)
235214
thrown.getMessage should include("cannot validate certificate")
236215
} finally {
@@ -239,20 +218,6 @@ class WskConfigTests extends TestHelpers with WskTestHelpers {
239218
}
240219
}
241220

242-
it should "ensure default namespace is used when a blank namespace is set" in {
243-
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
244-
try {
245-
val writer = new BufferedWriter(new FileWriter(tmpwskprops))
246-
writer.write(s"NAMESPACE=")
247-
writer.close()
248-
val env = Map("WSK_CONFIG_FILE" -> tmpwskprops.getAbsolutePath())
249-
val stdout = wsk.cli(Seq("property", "get", "-i", "--namespace"), env = env).stdout
250-
stdout should include regex ("whisk namespace\\s+_")
251-
} finally {
252-
tmpwskprops.delete()
253-
}
254-
}
255-
256221
it should "show api build version using property file" in {
257222
val tmpwskprops = File.createTempFile("wskprops", ".tmp")
258223
try {

0 commit comments

Comments
 (0)