mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
tests: add hcl task driver config parsing tests (#5314)
* drivers: add config parsing tests Add basic tests for parsing and encoding task config. * drivers/docker: fix some config declarations * refactor and document config parse helpers
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
ctestutil "github.com/hashicorp/nomad/client/testutil"
|
||||
"github.com/hashicorp/nomad/helper/pluginutils/hclutils"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
@@ -291,3 +292,27 @@ func copyFile(src, dst string, t *testing.T) {
|
||||
t.Fatalf("copying %v -> %v failed: %v", src, dst, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfig_ParseAllHCL(t *testing.T) {
|
||||
cfgStr := `
|
||||
config {
|
||||
class = "java.main"
|
||||
class_path = "/tmp/cp"
|
||||
jar_path = "/tmp/jar.jar"
|
||||
jvm_options = ["-Xmx600"]
|
||||
args = ["arg1", "arg2"]
|
||||
}`
|
||||
|
||||
expected := &TaskConfig{
|
||||
Class: "java.main",
|
||||
ClassPath: "/tmp/cp",
|
||||
JarPath: "/tmp/jar.jar",
|
||||
JvmOpts: []string{"-Xmx600"},
|
||||
Args: []string{"arg1", "arg2"},
|
||||
}
|
||||
|
||||
var tc *TaskConfig
|
||||
hclutils.NewConfigParser(taskConfigSpec).ParseHCL(t, cfgStr, &tc)
|
||||
|
||||
require.EqualValues(t, expected, tc)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user