From b1c6a3f63f97cfb174b894e332f26e5f6225ef56 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Fri, 10 Apr 2015 00:50:48 +0200 Subject: [PATCH] Few small fixes to make the last tests also pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reason why the shebang is removed from these tests, is because the shebang is only needed for SSH/Linux connections. So in the new setup the shebang line is added in the SSH communicator instead of in the resource provisioner itself… --- .../remote-exec/resource_provisioner_test.go | 23 +++++++++---------- .../remote-exec/test-fixtures/script1.sh | 1 - 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/builtin/provisioners/remote-exec/resource_provisioner_test.go b/builtin/provisioners/remote-exec/resource_provisioner_test.go index 47a723947..a10520fb8 100644 --- a/builtin/provisioners/remote-exec/resource_provisioner_test.go +++ b/builtin/provisioners/remote-exec/resource_provisioner_test.go @@ -41,6 +41,11 @@ func TestResourceProvider_Validate_bad(t *testing.T) { } } +var expectedScriptOut = `cd /tmp +wget http://foobar +exit 0 +` + func TestResourceProvider_generateScript(t *testing.T) { p := new(ResourceProvisioner) conf := testConfig(t, map[string]interface{}{ @@ -60,12 +65,6 @@ func TestResourceProvider_generateScript(t *testing.T) { } } -var expectedScriptOut = `#!/bin/sh -cd /tmp -wget http://foobar -exit 0 -` - func TestResourceProvider_CollectScripts_inline(t *testing.T) { p := new(ResourceProvisioner) conf := testConfig(t, map[string]interface{}{ @@ -91,8 +90,8 @@ func TestResourceProvider_CollectScripts_inline(t *testing.T) { t.Fatalf("err: %v", err) } - if string(out.Bytes()) != expectedScriptOut { - t.Fatalf("bad: %v", out.Bytes()) + if out.String() != expectedScriptOut { + t.Fatalf("bad: %v", out.String()) } } @@ -117,8 +116,8 @@ func TestResourceProvider_CollectScripts_script(t *testing.T) { t.Fatalf("err: %v", err) } - if string(out.Bytes()) != expectedScriptOut { - t.Fatalf("bad: %v", out.Bytes()) + if out.String() != expectedScriptOut { + t.Fatalf("bad: %v", out.String()) } } @@ -148,8 +147,8 @@ func TestResourceProvider_CollectScripts_scripts(t *testing.T) { t.Fatalf("err: %v", err) } - if string(out.Bytes()) != expectedScriptOut { - t.Fatalf("bad: %v", out.Bytes()) + if out.String() != expectedScriptOut { + t.Fatalf("bad: %v", out.String()) } } } diff --git a/builtin/provisioners/remote-exec/test-fixtures/script1.sh b/builtin/provisioners/remote-exec/test-fixtures/script1.sh index cd22f3e63..81b3d5af8 100755 --- a/builtin/provisioners/remote-exec/test-fixtures/script1.sh +++ b/builtin/provisioners/remote-exec/test-fixtures/script1.sh @@ -1,4 +1,3 @@ -#!/bin/sh cd /tmp wget http://foobar exit 0