From c60dbd9d13396ffe96f7efbbffa8ece0786b4113 Mon Sep 17 00:00:00 2001 From: Matt Schuchard Date: Thu, 12 Dec 2024 16:40:48 -0500 Subject: [PATCH] reorganize main and tests structure --- Makefile | 4 ++-- {provisioner/fixtures => fixtures}/Vagrantfile | 0 {provisioner/fixtures => fixtures}/test.pkr.hcl | 0 {provisioner/fixtures => fixtures}/test.py | 0 main.go | 6 +++--- provisioner/acceptance_test.go => main_test.go | 2 +- provisioner/testinfra_test.go | 6 +++--- 7 files changed, 9 insertions(+), 9 deletions(-) rename {provisioner/fixtures => fixtures}/Vagrantfile (100%) rename {provisioner/fixtures => fixtures}/test.pkr.hcl (100%) rename {provisioner/fixtures => fixtures}/test.py (100%) rename provisioner/acceptance_test.go => main_test.go (99%) diff --git a/Makefile b/Makefile index 649d9da..daf4776 100644 --- a/Makefile +++ b/Makefile @@ -13,11 +13,11 @@ install: build @packer plugins install --path ./packer-plugin-testinfra 'github.com/mschuchard/testinfra' unit: - @go test -v ./... + @go test -v ./provisioner accept: install # start vbox machine for ssh communicator testing - @PACKER_ACC=1 go test -v ./provisioner/testinfra_acceptance_test.go -timeout=1m + @PACKER_ACC=1 go test -v ./main_test.go -timeout=1m install-packer-sdc: @go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest diff --git a/provisioner/fixtures/Vagrantfile b/fixtures/Vagrantfile similarity index 100% rename from provisioner/fixtures/Vagrantfile rename to fixtures/Vagrantfile diff --git a/provisioner/fixtures/test.pkr.hcl b/fixtures/test.pkr.hcl similarity index 100% rename from provisioner/fixtures/test.pkr.hcl rename to fixtures/test.pkr.hcl diff --git a/provisioner/fixtures/test.py b/fixtures/test.py similarity index 100% rename from provisioner/fixtures/test.py rename to fixtures/test.py diff --git a/main.go b/main.go index 4dea4fa..b0825ce 100644 --- a/main.go +++ b/main.go @@ -10,12 +10,12 @@ import ( ) func main() { - // initialize plugin version - pluginVersion := version.NewPluginVersion("1.4.2", "", "") - // initialize packer plugin set for testinfra packerPluginSet := plugin.NewSet() + // register plugin provisioner packerPluginSet.RegisterProvisioner(plugin.DEFAULT_NAME, new(testinfra.Provisioner)) + // set plugin version + pluginVersion := version.NewPluginVersion("1.4.2", "", "") packerPluginSet.SetVersion(pluginVersion) // execute packer plugin for testinfra diff --git a/provisioner/acceptance_test.go b/main_test.go similarity index 99% rename from provisioner/acceptance_test.go rename to main_test.go index 8207cd8..dc99080 100644 --- a/provisioner/acceptance_test.go +++ b/main_test.go @@ -1,4 +1,4 @@ -package testinfra +package main import ( _ "embed" diff --git a/provisioner/testinfra_test.go b/provisioner/testinfra_test.go index 7bcb7fe..794a16b 100644 --- a/provisioner/testinfra_test.go +++ b/provisioner/testinfra_test.go @@ -24,7 +24,7 @@ var basicConfig = &Config{ PytestPath: "/usr/local/bin/py.test", Sudo: true, SudoUser: "fooman", - TestFiles: []string{"fixtures/test.py"}, + TestFiles: []string{"../fixtures/test.py"}, Verbose: 2, } @@ -139,7 +139,7 @@ func TestProvisionerPrepareNonExistFiles(test *testing.T) { // test no pytest var noPytestConfig = &Config{ PytestPath: "/home/foo/py.test", - TestFiles: []string{"fixtures/test.py"}, + TestFiles: []string{"../fixtures/test.py"}, } err := provisioner.Prepare(noPytestConfig) @@ -151,7 +151,7 @@ func TestProvisionerPrepareNonExistFiles(test *testing.T) { // test nonexistent testfile var noTestFileConfig = &Config{ PytestPath: "/usr/local/bin/py.test", - TestFiles: []string{"fixtures/test.py", "/home/foo/test.py"}, + TestFiles: []string{"../fixtures/test.py", "/home/foo/test.py"}, } if !CI {