Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Feb 5, 2016
1 parent 8b55fd6 commit 0c46a0e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions client/driver/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func testTaskEnvironment() *TaskEnvironment {
func TestEnvironment_ParseAndReplace_Env(t *testing.T) {
env := testTaskEnvironment()

input := []string{fmt.Sprintf(`"$%v"!`, envOneKey), fmt.Sprintf("$%s$%s", envOneKey, envTwoKey)}
input := []string{fmt.Sprintf(`"${%v}"!`, envOneKey), fmt.Sprintf("${%s}${%s}", envOneKey, envTwoKey)}
act := env.ParseAndReplace(input)
exp := []string{fmt.Sprintf(`"%s"!`, envOneVal), fmt.Sprintf("%s%s", envOneVal, envTwoVal)}

Expand All @@ -71,7 +71,7 @@ func TestEnvironment_ParseAndReplace_Env(t *testing.T) {
}

func TestEnvironment_ParseAndReplace_Meta(t *testing.T) {
input := []string{fmt.Sprintf("$%v%v", nodeMetaPrefix, metaKey)}
input := []string{fmt.Sprintf("${%v%v}", nodeMetaPrefix, metaKey)}
exp := []string{metaVal}
env := testTaskEnvironment()
act := env.ParseAndReplace(input)
Expand All @@ -82,7 +82,7 @@ func TestEnvironment_ParseAndReplace_Meta(t *testing.T) {
}

func TestEnvironment_ParseAndReplace_Attr(t *testing.T) {
input := []string{fmt.Sprintf("$%v%v", nodeAttributePrefix, attrKey)}
input := []string{fmt.Sprintf("${%v%v}", nodeAttributePrefix, attrKey)}
exp := []string{attrVal}
env := testTaskEnvironment()
act := env.ParseAndReplace(input)
Expand All @@ -93,7 +93,7 @@ func TestEnvironment_ParseAndReplace_Attr(t *testing.T) {
}

func TestEnvironment_ParseAndReplace_Node(t *testing.T) {
input := []string{fmt.Sprintf("$%v", nodeNameKey), fmt.Sprintf("$%v", nodeClassKey)}
input := []string{fmt.Sprintf("${%v}", nodeNameKey), fmt.Sprintf("${%v}", nodeClassKey)}
exp := []string{nodeName, nodeClass}
env := testTaskEnvironment()
act := env.ParseAndReplace(input)
Expand All @@ -105,9 +105,9 @@ func TestEnvironment_ParseAndReplace_Node(t *testing.T) {

func TestEnvironment_ParseAndReplace_Mixed(t *testing.T) {
input := []string{
fmt.Sprintf("$%v$%v%v", nodeNameKey, nodeAttributePrefix, attrKey),
fmt.Sprintf("$%v$%v%v", nodeClassKey, nodeMetaPrefix, metaKey),
fmt.Sprintf("$%v$%v", envTwoKey, nodeClassKey),
fmt.Sprintf("${%v}${%v%v}", nodeNameKey, nodeAttributePrefix, attrKey),
fmt.Sprintf("${%v}${%v%v}", nodeClassKey, nodeMetaPrefix, metaKey),
fmt.Sprintf("${%v}${%v}", envTwoKey, nodeClassKey),
}
exp := []string{
fmt.Sprintf("%v%v", nodeName, attrVal),
Expand All @@ -123,7 +123,7 @@ func TestEnvironment_ParseAndReplace_Mixed(t *testing.T) {
}

func TestEnvironment_ReplaceEnv_Mixed(t *testing.T) {
input := fmt.Sprintf("$%v$%v%v", nodeNameKey, nodeAttributePrefix, attrKey)
input := fmt.Sprintf("${%v}${%v%v}", nodeNameKey, nodeAttributePrefix, attrKey)
exp := fmt.Sprintf("%v%v", nodeName, attrVal)
env := testTaskEnvironment()
act := env.ReplaceEnv(input)
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestEnvironment_ClearEnvvars(t *testing.T) {

func TestEnvironment_Interprolate(t *testing.T) {
env := testTaskEnvironment().
SetEnvvars(map[string]string{"test": "$node.class", "test2": "$attr.arch"}).
SetEnvvars(map[string]string{"test": "${node.class}", "test2": "${attr.arch}"}).
Build()

act := env.EnvList()
Expand Down
2 changes: 1 addition & 1 deletion client/driver/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func TestExecDriver_Start_Wait_AllocDir(t *testing.T) {
"command": "/bin/bash",
"args": []string{
"-c",
fmt.Sprintf(`sleep 1; echo -n %s > $%s/%s`, string(exp), env.AllocDir, file),
fmt.Sprintf(`sleep 1; echo -n %s > ${%s}/%s`, string(exp), env.AllocDir, file),
},
},
Resources: basicResources,
Expand Down
2 changes: 1 addition & 1 deletion client/driver/raw_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestRawExecDriver_Start_Wait_AllocDir(t *testing.T) {
t.Parallel()
exp := []byte{'w', 'i', 'n'}
file := "output.txt"
outPath := fmt.Sprintf(`$%s/%s`, env.AllocDir, file)
outPath := fmt.Sprintf(`${%s}/%s`, env.AllocDir, file)
task := &structs.Task{
Name: "sleep",
Config: map[string]interface{}{
Expand Down

0 comments on commit 0c46a0e

Please sign in to comment.