diff options
author | Martin Polden <mpolden@mpolden.no> | 2022-04-28 13:26:55 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2022-04-28 13:30:14 +0200 |
commit | 47f01120580f08521ce0c24adb315709433f8145 (patch) | |
tree | 12eb10f08e636271c2606f25e0837292ad8b2b12 /client | |
parent | d76f3eaf68868e38df6a085ddfec2ba483599289 (diff) |
Support having 'tests' in root of application package
Diffstat (limited to 'client')
-rw-r--r-- | client/go/vespa/application.go | 13 | ||||
-rw-r--r-- | client/go/vespa/deploy_test.go | 13 |
2 files changed, 20 insertions, 6 deletions
diff --git a/client/go/vespa/application.go b/client/go/vespa/application.go index c03f4d6f644..06c643c2b3f 100644 --- a/client/go/vespa/application.go +++ b/client/go/vespa/application.go @@ -215,13 +215,18 @@ func FindApplicationPackage(zipOrDir string, requirePackaging bool) (Application } } if path := filepath.Join(zipOrDir, "src", "main", "application"); util.PathExists(path) { - if testPath := filepath.Join(zipOrDir, "src", "test", "application"); util.PathExists(testPath) { - return ApplicationPackage{Path: path, TestPath: testPath}, nil + testPath := "" + if d := filepath.Join(zipOrDir, "src", "test", "application"); util.PathExists(d) { + testPath = d } - return ApplicationPackage{Path: path}, nil + return ApplicationPackage{Path: path, TestPath: testPath}, nil } if util.PathExists(filepath.Join(zipOrDir, "services.xml")) { - return ApplicationPackage{Path: zipOrDir}, nil + testPath := "" + if util.PathExists(filepath.Join(zipOrDir, "tests")) { + testPath = zipOrDir + } + return ApplicationPackage{Path: zipOrDir, TestPath: testPath}, nil } return ApplicationPackage{}, fmt.Errorf("could not find an application package source in '%s'", zipOrDir) } diff --git a/client/go/vespa/deploy_test.go b/client/go/vespa/deploy_test.go index 297d028ee91..a56d537026c 100644 --- a/client/go/vespa/deploy_test.go +++ b/client/go/vespa/deploy_test.go @@ -102,8 +102,9 @@ func TestFindApplicationPackage(t *testing.T) { existingFile: filepath.Join(dir, "src", "main", "application") + string(os.PathSeparator), }) assertFindApplicationPackage(t, dir, pkgFixture{ - expectedPath: filepath.Join(dir, "src", "main", "application"), - existingFile: filepath.Join(dir, "pom.xml"), + expectedPath: filepath.Join(dir, "src", "main", "application"), + expectedTestPath: filepath.Join(dir, "src", "test", "application"), + existingFiles: []string{filepath.Join(dir, "pom.xml"), filepath.Join(dir, "src/test/application/tests/foo.json")}, }) assertFindApplicationPackage(t, dir, pkgFixture{ existingFile: filepath.Join(dir, "pom.xml"), @@ -115,10 +116,17 @@ func TestFindApplicationPackage(t *testing.T) { existingFiles: []string{filepath.Join(dir, "pom.xml"), filepath.Join(dir, "target", "application.zip")}, requirePackaging: true, }) + dir2 := t.TempDir() + assertFindApplicationPackage(t, dir2, pkgFixture{ + expectedPath: dir2, + expectedTestPath: dir2, + existingFiles: []string{filepath.Join(dir2, "services.xml"), filepath.Join(dir2, "tests", "foo.json")}, + }) } type pkgFixture struct { expectedPath string + expectedTestPath string existingFile string existingFiles []string requirePackaging bool @@ -136,6 +144,7 @@ func assertFindApplicationPackage(t *testing.T, zipOrDir string, fixture pkgFixt pkg, err := FindApplicationPackage(zipOrDir, fixture.requirePackaging) assert.Equal(t, err != nil, fixture.fail, "Expected error for "+zipOrDir) assert.Equal(t, fixture.expectedPath, pkg.Path) + assert.Equal(t, fixture.expectedTestPath, pkg.TestPath) } func writeFile(t *testing.T, name string) { |