Skip to content

Commit

Permalink
reorganize main and tests structure
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Dec 12, 2024
1 parent 64d93a1 commit c60dbd9
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion provisioner/acceptance_test.go → main_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package testinfra
package main

import (
_ "embed"
Expand Down
6 changes: 3 additions & 3 deletions provisioner/testinfra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit c60dbd9

Please sign in to comment.