aboutsummaryrefslogtreecommitdiffstats
path: root/client/go/cmd
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-11-18 09:55:21 +0100
committerMartin Polden <mpolden@mpolden.no>2022-11-18 09:55:21 +0100
commitadba4c67cb1bb366cc39858ce549a8ded554ed3c (patch)
tree1e9ff53f9bf36ac7ba8ebf7344c6448831004496 /client/go/cmd
parent2872e68c64605c04147fbf930d76f09078ce5550 (diff)
Do not require tests in prod submit
Fixes #24907
Diffstat (limited to 'client/go/cmd')
-rw-r--r--client/go/cmd/prod.go3
-rw-r--r--client/go/cmd/prod_test.go25
2 files changed, 22 insertions, 6 deletions
diff --git a/client/go/cmd/prod.go b/client/go/cmd/prod.go
index 46b7a673215..6b5470aaa6c 100644
--- a/client/go/cmd/prod.go
+++ b/client/go/cmd/prod.go
@@ -363,6 +363,9 @@ func prompt(cli *CLI, stdin *bufio.Reader, question, defaultAnswer string, valid
}
func verifyTests(cli *CLI, app vespa.ApplicationPackage) error {
+ if !app.HasTests() {
+ return nil
+ }
// TODO: system-test, staging-setup and staging-test should be required if the application
// does not have any Java tests.
suites := map[string]bool{
diff --git a/client/go/cmd/prod_test.go b/client/go/cmd/prod_test.go
index eff06cf860e..c9584511203 100644
--- a/client/go/cmd/prod_test.go
+++ b/client/go/cmd/prod_test.go
@@ -17,7 +17,7 @@ import (
func TestProdInit(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, false)
+ createApplication(t, pkgDir, false, false)
answers := []string{
// Regions
@@ -85,7 +85,7 @@ func readFileString(t *testing.T, filename string) string {
return string(content)
}
-func createApplication(t *testing.T, pkgDir string, java bool) {
+func createApplication(t *testing.T, pkgDir string, java bool, skipTests bool) {
appDir := filepath.Join(pkgDir, "src", "main", "application")
targetDir := filepath.Join(pkgDir, "target")
if err := os.MkdirAll(appDir, 0755); err != nil {
@@ -125,10 +125,13 @@ func createApplication(t *testing.T, pkgDir string, java bool) {
t.Fatal(err)
}
if java {
+ if skipTests {
+ t.Fatalf("skipTests=%t has no effect when java=%t", skipTests, java)
+ }
if err := os.WriteFile(filepath.Join(pkgDir, "pom.xml"), []byte(""), 0644); err != nil {
t.Fatal(err)
}
- } else {
+ } else if !skipTests {
testsDir := filepath.Join(pkgDir, "src", "test", "application", "tests")
testBytes, _ := io.ReadAll(strings.NewReader("{\"steps\":[{}]}"))
writeTest(filepath.Join(testsDir, "system-test", "test.json"), testBytes, t)
@@ -148,8 +151,18 @@ func writeTest(path string, content []byte, t *testing.T) {
func TestProdSubmit(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, false)
+ createApplication(t, pkgDir, false, false)
+ prodSubmit(pkgDir, t)
+}
+
+func TestProdSubmitWithoutTests(t *testing.T) {
+ pkgDir := filepath.Join(t.TempDir(), "app")
+ createApplication(t, pkgDir, false, true)
+ prodSubmit(pkgDir, t)
+}
+func prodSubmit(pkgDir string, t *testing.T) {
+ t.Helper()
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)
@@ -192,7 +205,7 @@ func TestProdSubmit(t *testing.T) {
func TestProdSubmitWithJava(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, true)
+ createApplication(t, pkgDir, true, false)
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)
@@ -219,7 +232,7 @@ func TestProdSubmitWithJava(t *testing.T) {
func TestProdSubmitInvalidZip(t *testing.T) {
pkgDir := filepath.Join(t.TempDir(), "app")
- createApplication(t, pkgDir, true)
+ createApplication(t, pkgDir, true, false)
httpClient := &mock.HTTPClient{}
httpClient.NextResponseString(200, `ok`)