warrensbox/terraform-switcher

Why is the test for linux including build tasks?

Closed this issue ยท 3 comments

I was looking at the integration tests and i don't understand wha the code for the linux tests is at it is

run: |
set -e
go get -v -t -d ./...
go vet -tests=false ./...
go test -v ./...
mkdir -p build
go build -v -o build/tfswitch
mkdir `pwd`/bin/
find ./test-data/* -type d -print0 | while read -r -d $'\0' TEST_PATH; do
./build/tfswitch -c "${TEST_PATH}" -b `pwd`/bin/terraform || exit 1
done

I looks like it is

  • get dependecies (what should be done with actions/setup-go already
  • go vet (which might be useful for windows tests too)
  • go test (necessary of course)
  • create build dir (why?)
  • build tfswitch (again why? these are integration tests)
  • create /bin dir (why?)
  • iterate the test-data folders and execute the built binary with them as changedir params. (i can see that this MIGHT be useful, but this should be covered in the test definitions. Did that in #356)

Maybe there is something i don't get. If that is the case: please enlighten me ๐Ÿ˜

If that is a good approach: Why not doing it with windows test as well?

As of look of it, this bit comes from the past and suspectedly was used to test switching different TF versions with fresh-built tfswitch.

create build dir (why?)

Maybe older versions of Go couldn't create output dirs? ๐Ÿค”

build tfswitch (again why? these are integration tests)

To use freshly built binary to conduct tests ๐Ÿ˜บ

create /bin dir (why?)

To prevent tfswitch from failing on non-existent dest dir for -b cmdline option.

I tried my best in theoretical reasoning ๐Ÿ˜‚
Probs @warrensbox can try and recall why that is as it is.

@MatrixCrawler this was implemented awhile back. I think @jukie helped with this tests. It was more of an integration test.
I am open to switching it to unit tests - like what you were doing with #356

Thanks for optimizing the test as well.

Tanks for the info ๐Ÿ˜„