summaryrefslogtreecommitdiffstats
path: root/model/manifest_test.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-07-17 18:47:05 -0400
committerChristopher Speller <crspeller@gmail.com>2018-07-17 15:47:05 -0700
commite718d2544f6c719bc6e31f569400f44d54de3a34 (patch)
treebe01ad094f309d49092685b4ea377c2ed12904b0 /model/manifest_test.go
parentf2c180390599e66fee2f1a8c1a4ab52eea920c51 (diff)
downloadchat-e718d2544f6c719bc6e31f569400f44d54de3a34.tar.gz
chat-e718d2544f6c719bc6e31f569400f44d54de3a34.tar.bz2
chat-e718d2544f6c719bc6e31f569400f44d54de3a34.zip
MM-11366: support a plugin bundle with multiple executables (#9121)
This avoids the need to distribute multiple plugins per architecture.
Diffstat (limited to 'model/manifest_test.go')
-rw-r--r--model/manifest_test.go167
1 files changed, 166 insertions, 1 deletions
diff --git a/model/manifest_test.go b/model/manifest_test.go
index 0c55b5b66..e264a73c8 100644
--- a/model/manifest_test.go
+++ b/model/manifest_test.go
@@ -66,6 +66,11 @@ func TestManifestUnmarshal(t *testing.T) {
Id: "theid",
Backend: &ManifestBackend{
Executable: "theexecutable",
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "theexecutable-linux-amd64",
+ DarwinAmd64: "theexecutable-darwin-amd64",
+ WindowsAmd64: "theexecutable-windows-amd64",
+ },
},
Webapp: &ManifestWebapp{
BundlePath: "thebundlepath",
@@ -98,6 +103,10 @@ func TestManifestUnmarshal(t *testing.T) {
id: theid
backend:
executable: theexecutable
+ executables:
+ linux-amd64: theexecutable-linux-amd64
+ darwin-amd64: theexecutable-darwin-amd64
+ windows-amd64: theexecutable-windows-amd64
webapp:
bundle_path: thebundlepath
settings_schema:
@@ -121,7 +130,12 @@ settings_schema:
require.NoError(t, json.Unmarshal([]byte(`{
"id": "theid",
"backend": {
- "executable": "theexecutable"
+ "executable": "theexecutable",
+ "executables": {
+ "linux-amd64": "theexecutable-linux-amd64",
+ "darwin-amd64": "theexecutable-darwin-amd64",
+ "windows-amd64": "theexecutable-windows-amd64"
+ }
},
"webapp": {
"bundle_path": "thebundlepath"
@@ -283,3 +297,154 @@ func TestManifestClientManifest(t *testing.T) {
assert.NotEmpty(t, manifest.Backend)
assert.NotEmpty(t, manifest.SettingsSchema)
}
+
+func TestManifestGetExecutableForRuntime(t *testing.T) {
+ testCases := []struct {
+ Description string
+ Manifest *Manifest
+ GoOs string
+ GoArch string
+ ExpectedExecutable string
+ }{
+ {
+ "no backend",
+ &Manifest{},
+ "linux",
+ "amd64",
+ "",
+ },
+ {
+ "no executable",
+ &Manifest{
+ Backend: &ManifestBackend{},
+ },
+ "linux",
+ "amd64",
+ "",
+ },
+ {
+ "single executable",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executable: "path/to/executable",
+ },
+ },
+ "linux",
+ "amd64",
+ "path/to/executable",
+ },
+ {
+ "single executable, different runtime",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executable: "path/to/executable",
+ },
+ },
+ "darwin",
+ "amd64",
+ "path/to/executable",
+ },
+ {
+ "multiple executables, no match",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ },
+ },
+ "other",
+ "amd64",
+ "",
+ },
+ {
+ "multiple executables, linux-amd64 match",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ },
+ },
+ "linux",
+ "amd64",
+ "linux-amd64/path/to/executable",
+ },
+ {
+ "multiple executables, linux-amd64 match, single executable ignored",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ Executable: "path/to/executable",
+ },
+ },
+ "linux",
+ "amd64",
+ "linux-amd64/path/to/executable",
+ },
+ {
+ "multiple executables, darwin-amd64 match",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ },
+ },
+ "darwin",
+ "amd64",
+ "darwin-amd64/path/to/executable",
+ },
+ {
+ "multiple executables, windows-amd64 match",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ },
+ },
+ "windows",
+ "amd64",
+ "windows-amd64/path/to/executable",
+ },
+ {
+ "multiple executables, no match, single executable fallback",
+ &Manifest{
+ Backend: &ManifestBackend{
+ Executables: &ManifestExecutables{
+ LinuxAmd64: "linux-amd64/path/to/executable",
+ DarwinAmd64: "darwin-amd64/path/to/executable",
+ WindowsAmd64: "windows-amd64/path/to/executable",
+ },
+ Executable: "path/to/executable",
+ },
+ },
+ "other",
+ "amd64",
+ "path/to/executable",
+ },
+ }
+
+ for _, testCase := range testCases {
+ t.Run(testCase.Description, func(t *testing.T) {
+ assert.Equal(
+ t,
+ testCase.ExpectedExecutable,
+ testCase.Manifest.GetExecutableForRuntime(testCase.GoOs, testCase.GoArch),
+ )
+ })
+ }
+}