genesis-community / testkit

Kit test framework for validating kits generate manifests correctly for a variety of input environment files.
MIT License
0 stars 4 forks source link

bosh int doesn't work for scenarios without bosh variables #2

Open dennisjbell opened 4 years ago

dennisjbell commented 4 years ago

Getting the following error when testing on a bosh 1.x line:

• Failure [8.380 seconds]
BOSH Kit
/Users/dbell/code/src/github.com/genesis-community/bosh-genesis-kit/spec/spec_test.go:11
  cpis
  /Users/dbell/code/src/github.com/genesis-community/bosh-genesis-kit/spec/spec_test.go:48
    given a environment manifest: spec/deployments/aws.yml
    /Users/dbell/lib/go/pkg/mod/github.com/genesis-community/testkit@v0.0.0-20200511145056-e869f02cb68b/testing/testing.go:72
      renders a manifest which matches: spec/results/aws.yml [It]
      /Users/dbell/lib/go/pkg/mod/github.com/genesis-community/testkit@v0.0.0-20200511145056-e869f02cb68b/testing/testing.go:49

      Expected
          <int>: -1
      to equal
          <int>: 0

      /Users/dbell/lib/go/pkg/mod/github.com/genesis-community/testkit@v0.0.0-20200511145056-e869f02cb68b/testing/bosh.go:42

This version of the bosh kit doesn't use bosh-variables, which results in having an empty hash as the value, which seems to result in bosh int returning a -1 without stderr or stdout output. My naive solution is to apply the following to testing/testing.go, but there may be a more golang-way of doing it.

53c53,56
<                       manifest := b.Interpolate(manifestResult.raw, manifestResult.boshVariables)
---
>                       manifest := manifestResult.raw
>                       if string(manifestResult.boshVariables) != "{}\n" {
>                               manifest = b.Interpolate(manifestResult.raw, manifestResult.boshVariables)
>                       }
rkoster commented 4 years ago

which version of the bosh-cli did you use? Asking because there are tests for this case already in the spec dir, baseline.yml for example does not use bosh-variables.

rkoster commented 4 years ago

was related to bosh being a bash function on the reports system. Could be fixed by using bosh via the go library