summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-08-26 08:45:16 +0200
committerJon Bratseth <bratseth@gmail.com>2021-08-26 08:45:16 +0200
commit578349e35e13399ae504756de057c47c81c776b8 (patch)
tree448ca4bb5cac38642b1b463348e104b3b3a42e21 /client
parent524dbdd224a39fb5537687a95ea16ab524db1338 (diff)
Improve messages
Diffstat (limited to 'client')
-rw-r--r--client/go/cmd/deploy_test.go54
-rw-r--r--client/go/cmd/document.go2
-rw-r--r--client/go/cmd/document_test.go2
-rw-r--r--client/go/vespa/deploy.go2
4 files changed, 27 insertions, 33 deletions
diff --git a/client/go/cmd/deploy_test.go b/client/go/cmd/deploy_test.go
index 9042bc2c2a8..502c247b3f5 100644
--- a/client/go/cmd/deploy_test.go
+++ b/client/go/cmd/deploy_test.go
@@ -12,54 +12,42 @@ import (
)
func TestDeployZip(t *testing.T) {
- client := &mockHttpClient{}
- assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withTarget/target/application.zip"}, []string{}))
- assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+ assertDeploy("testdata/applications/withTarget/target/application.zip",
+ []string{"deploy", "testdata/applications/withTarget/target/application.zip"}, t)
}
func TestDeployZipWithURLTargetArgument(t *testing.T) {
+ applicationPackage := "testdata/applications/withTarget/target/application.zip"
+ arguments := []string{"deploy", "testdata/applications/withTarget/target/application.zip", "-t", "http://target:19071"}
+
client := &mockHttpClient{}
assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withTarget/target/application.zip", "-t", "http://target:19071"}, []string{}))
+ "\x1b[32mDeployed "+applicationPackage+"\x1b[0m\n",
+ executeCommand(t, client, arguments, []string{}))
assertDeployRequestMade("http://target:19071", client, t)
}
func TestDeployZipWitLocalTargetArgument(t *testing.T) {
- client := &mockHttpClient{}
- assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withTarget/target/application.zip", "-t", "local"}, []string{}))
- assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+ assertDeploy("testdata/applications/withTarget/target/application.zip",
+ []string{"deploy", "testdata/applications/withTarget/target/application.zip", "-t", "local"}, t)
}
func TestDeploySourceDirectory(t *testing.T) {
- client := &mockHttpClient{}
- assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withSource/src/main/application"}, []string{}))
- assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+ assertDeploy("testdata/applications/withSource/src/main/application",
+ []string{"deploy", "testdata/applications/withSource/src/main/application"}, t)
}
func TestDeployApplicationDirectoryWithSource(t *testing.T) {
- client := &mockHttpClient{}
- assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withSource"}, []string{}))
- assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+ assertDeploy("testdata/applications/withSource/src/main/application",
+ []string{"deploy", "testdata/applications/withSource"}, t)
}
-func TestDeployApplicationDirectoryWithTarget(t *testing.T) {
- client := &mockHttpClient{}
- assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
- executeCommand(t, client, []string{"deploy", "testdata/applications/withTarget"}, []string{}))
- assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+func TestDeployApplicationDirectoryWithPomAndTarget(t *testing.T) {
+ assertDeploy("testdata/applications/withTarget/target/application.zip",
+ []string{"deploy", "testdata/applications/withTarget"}, t)
}
-func TestDeployApplicationDirectoryWithEmptyTarget(t *testing.T) {
+func TestDeployApplicationDirectoryWithPomAndEmptyTarget(t *testing.T) {
client := &mockHttpClient{}
assert.Equal(t,
"\x1b[31mno application package found in testdata/applications/withEmptyTarget\x1b[0m\n",
@@ -74,7 +62,13 @@ func TestDeployError(t *testing.T) {
assertDeployServerError(t, 501, "Deploy service error")
}
-// TODO: Test prepare and activate prepared
+func assertDeploy(applicationPackage string, arguments []string, t *testing.T) {
+ client := &mockHttpClient{}
+ assert.Equal(t,
+ "\x1b[32mDeployed "+applicationPackage+"\x1b[0m\n",
+ executeCommand(t, client, arguments, []string{}))
+ assertDeployRequestMade("http://127.0.0.1:19071", client, t)
+}
func assertDeployRequestMade(target string, client *mockHttpClient, t *testing.T) {
assert.Equal(t, target+"/application/v2/tenant/default/prepareandactivate", client.lastRequest.URL.String())
diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go
index 176e78bc14b..68e583d4c29 100644
--- a/client/go/cmd/document.go
+++ b/client/go/cmd/document.go
@@ -103,7 +103,7 @@ func post(documentId string, jsonFile string) {
defer response.Body.Close()
if response.StatusCode == 200 {
- util.Success("Success") // TODO: Change to something including document id
+ util.Success(documentId)
} else if response.StatusCode/100 == 4 {
util.Error("Invalid document (" + response.Status + "):")
util.PrintReader(response.Body)
diff --git a/client/go/cmd/document_test.go b/client/go/cmd/document_test.go
index 9f3bedc12e9..f1e4bc007cb 100644
--- a/client/go/cmd/document_test.go
+++ b/client/go/cmd/document_test.go
@@ -52,7 +52,7 @@ func TestDocumentPostServerError(t *testing.T) {
func assertDocumentPost(arguments []string, documentId string, jsonFile string, t *testing.T) {
client := &mockHttpClient{}
assert.Equal(t,
- "\x1b[32mSuccess\x1b[0m\n",
+ "\x1b[32m"+documentId+"\x1b[0m\n",
executeCommand(t, client, arguments, []string{}))
target := getTarget(documentContext).document
assert.Equal(t, target+"/document/v1/"+documentId, client.lastRequest.URL.String())
diff --git a/client/go/vespa/deploy.go b/client/go/vespa/deploy.go
index dec46a92b00..d0757d30aba 100644
--- a/client/go/vespa/deploy.go
+++ b/client/go/vespa/deploy.go
@@ -114,7 +114,7 @@ func Deploy(prepare bool, application string, target string) {
defer response.Body.Close()
if response.StatusCode == 200 {
- util.Success("Success")
+ util.Success("Deployed", pkg.Path)
} else if response.StatusCode/100 == 4 {
util.Error("Invalid application package", "("+response.Status+"):")
util.PrintReader(response.Body)