Skip to content

Commit

Permalink
Try to upload archive files also
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Templin committed Apr 2, 2018
1 parent e8752fb commit 83c1bf0
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 92 deletions.
48 changes: 46 additions & 2 deletions builtin/provisioners/chef/linux_provisioner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) {

p, err := decodeConfig(
schema.TestResourceDataRaw(t, Provisioner().(*schema.Provisioner).Schema, tc.Config),
"linux",
)
if err != nil {
t.Fatalf("Error: %v", err)
Expand Down Expand Up @@ -287,7 +288,7 @@ func TestResourceProvider_linuxCreateConfigFiles(t *testing.T) {
"LocalMode": {
Config: map[string]interface{}{
"use_local_mode": true,
"chef_repo": "tbd",
"chef_repo": os.TempDir(),
"run_list": []interface{}{"role[testrole]"},
"environment": "testenv",
"node_name": "testnode",
Expand All @@ -313,7 +314,7 @@ func TestResourceProvider_linuxCreateConfigFiles(t *testing.T) {
"LocalModePolicy": {
Config: map[string]interface{}{
"use_local_mode": true,
"chef_repo": "tbd",
"chef_repo": os.TempDir(),
"use_policyfile": true,
"policy_name": "testpolicy",
},
Expand Down Expand Up @@ -345,6 +346,7 @@ func TestResourceProvider_linuxCreateConfigFiles(t *testing.T) {

p, err := decodeConfig(
schema.TestResourceDataRaw(t, Provisioner().(*schema.Provisioner).Schema, tc.Config),
"linux",
)
if err != nil {
t.Fatalf("Error: %v", err)
Expand Down Expand Up @@ -468,6 +470,47 @@ func TestResourceProvider_linuxDeployChefRepo(t *testing.T) {
return testDeleteTmpFiles(self.Config["chef_repo"].(string))
},
},

"LocalModePolicyRepoFile": {
Config: map[string]interface{}{
"use_local_mode": true,
"chef_repo": "tbd",
"use_policyfile": true,
"policy_name": "testpolicy",
},

Commands: map[string]bool{
// prepare var dir for upload
"sudo mkdir -p " + linuxRepoDir: true,
"sudo chmod 777 " + linuxRepoDir: true,
"sudo " + fmt.Sprintf(chmod, linuxRepoDir, 666): true,
// client run
"sudo sh -c 'cd /var/chef && chef-client -z -j /etc/chef/first-boot.json'": true,
"sudo chef-client -z -j /etc/chef/first-boot.json": false,
},

Uploads: map[string]string{},

SetUp: func(t *testing.T, self createConfigTestCase) error {
archName := "testrepo.tgz"
layout := map[string][]string{
"": []string{archName},
}
tmpDir, err := testCreateTmpFiles(layout)
if err != nil {
return err
}

repoFile := path.Join(tmpDir, archName)
self.Config["chef_repo"] = repoFile
self.Uploads[path.Join(linuxRepoDir, archName)] = ""
return nil
},

TearDown: func(t *testing.T, self createConfigTestCase) error {
return testDeleteTmpFiles(self.Config["chef_repo"].(string))
},
},
}

o := new(terraform.MockUIOutput)
Expand All @@ -491,6 +534,7 @@ func TestResourceProvider_linuxDeployChefRepo(t *testing.T) {

p, err := decodeConfig(
schema.TestResourceDataRaw(t, Provisioner().(*schema.Provisioner).Schema, tc.Config),
"linux",
)
if err != nil {
t.Fatalf("Error: %v", err)
Expand Down
Loading

0 comments on commit 83c1bf0

Please sign in to comment.