diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-08-26 09:31:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-26 09:31:25 +0200 |
commit | a986acaa61f62243e5ca2fb7cdaa4ada8d0bc15a (patch) | |
tree | a117e6616e3ec7f77f85cf136ce53c1e34a32f51 /client | |
parent | 35027c422ff8802c37e06007ee86758c59251d68 (diff) | |
parent | 578349e35e13399ae504756de057c47c81c776b8 (diff) |
Merge pull request #18868 from vespa-engine/bratseth/improve-messages
Improve messages
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/deploy_test.go | 54 | ||||
-rw-r--r-- | client/go/cmd/document.go | 2 | ||||
-rw-r--r-- | client/go/cmd/document_test.go | 2 | ||||
-rw-r--r-- | client/go/vespa/deploy.go | 2 |
4 files changed, 27 insertions, 33 deletions
diff --git a/client/go/cmd/deploy_test.go b/client/go/cmd/deploy_test.go index 94936931dff..4a40739ec32 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[31mpom.xml exists but no target/application.zip. Run mvn package first\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 7be2455402b..badc97aa44b 100644 --- a/client/go/vespa/deploy.go +++ b/client/go/vespa/deploy.go @@ -113,7 +113,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) |