diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-02-03 15:20:23 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-02-03 15:35:25 +0100 |
commit | e1e94812425a487069bf33f781bec987e9e49874 (patch) | |
tree | 4a892c3b5c0a7dee2cb76f9971e538cb4aba8a16 /client/go/internal/mock/vespa.go | |
parent | a08ae588d6035b69f0961dff596fc871fd1c4e58 (diff) |
Re-organize Go code
Diffstat (limited to 'client/go/internal/mock/vespa.go')
-rw-r--r-- | client/go/internal/mock/vespa.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/go/internal/mock/vespa.go b/client/go/internal/mock/vespa.go new file mode 100644 index 00000000000..ca09a389360 --- /dev/null +++ b/client/go/internal/mock/vespa.go @@ -0,0 +1,39 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package mock + +import ( + "os" + "path/filepath" + "testing" +) + +// ApplicationPackageDir creates a mock application package directory using test helper t, returning the path to the +// "application" directory and the root directory where it was created. If java is true, create a file that indicates +// this package contains Java code. If cert is true, create an empty certificate file. +func ApplicationPackageDir(t *testing.T, java, cert bool) (string, string) { + t.Helper() + rootDir := t.TempDir() + appDir := filepath.Join(rootDir, "src", "main", "application") + if err := os.MkdirAll(appDir, 0755); err != nil { + t.Fatal(err) + } + servicesXML := filepath.Join(appDir, "services.xml") + if _, err := os.Create(servicesXML); err != nil { + t.Fatal(err) + } + if java { + if _, err := os.Create(filepath.Join(rootDir, "pom.xml")); err != nil { + t.Fatal(err) + } + } + if cert { + securityDir := filepath.Join(appDir, "security") + if err := os.MkdirAll(securityDir, 0755); err != nil { + t.Fatal(err) + } + if _, err := os.Create(filepath.Join(securityDir, "clients.pem")); err != nil { + t.Fatal(err) + } + } + return appDir, rootDir +} |