Refactor Nomad Command Generation.
- Abstracting from the exec form while generating. - Removal of single quotes (usage of only double-quotes). - Bash-nesting using escaping of special characters.
This commit is contained in:

committed by
Sebastian Serth

parent
f309d0f70e
commit
7dadc5dfe9
@ -96,9 +96,9 @@ func TestAWSFunctionWorkload_ExecuteInteractively(t *testing.T) {
|
||||
<-time.After(tests.ShortTimeout)
|
||||
cancel()
|
||||
|
||||
expectedRequestData := "{\"action\":\"" + environment.Image() +
|
||||
"\",\"cmd\":[\"env\",\"CODEOCEAN=true\",\"bash\",\"-c\",\"unset \\\"${!AWS@}\\\" \\u0026\\u0026 " + command +
|
||||
"\"],\"files\":{}}"
|
||||
expectedRequestData := `{"action":"` + environment.Image() +
|
||||
`","cmd":["/bin/bash","-c","env CODEOCEAN=true /bin/bash -c \"unset \\\"\\${!AWS@}\\\" \u0026\u0026 ` + command +
|
||||
`\""],"files":{}}`
|
||||
assert.Equal(t, expectedRequestData, awsMock.receivedData)
|
||||
})
|
||||
}
|
||||
@ -131,9 +131,9 @@ func TestAWSFunctionWorkload_UpdateFileSystem(t *testing.T) {
|
||||
<-time.After(tests.ShortTimeout)
|
||||
execCancel()
|
||||
|
||||
expectedRequestData := "{\"action\":\"" + environment.Image() +
|
||||
"\",\"cmd\":[\"env\",\"CODEOCEAN=true\",\"bash\",\"-c\",\"unset \\\"${!AWS@}\\\" \\u0026\\u0026 " + command +
|
||||
"\"]," + "\"files\":{\"" + string(myFile.Path) + "\":\"" + base64.StdEncoding.EncodeToString(myFile.Content) + "\"}}"
|
||||
expectedRequestData := `{"action":"` + environment.Image() +
|
||||
`","cmd":["/bin/bash","-c","env CODEOCEAN=true /bin/bash -c \"unset \\\"\\${!AWS@}\\\" \u0026\u0026 ` + command +
|
||||
`\""],"files":{"` + string(myFile.Path) + `":"` + base64.StdEncoding.EncodeToString(myFile.Content) + `"}}`
|
||||
assert.Equal(t, expectedRequestData, awsMock.receivedData)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user