diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bb46184f64..2a90352531 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,10 +54,12 @@ jobs: terraform_version: ${{ env.TF_VERSION }} terraform_wrapper: false + # avoid conflicts with user-installed providers on local machines - name: Pin provider versions run: | - sed -i 's/>=\(.*# tftest\)/=\1/g' default-versions.tf - find -name versions.tf -exec cp default-versions.tf {} \; + for f in $(find . -name versions.tf); do + sed -i 's/>=\(.*# tftest\)/=\1/g' $f; + done - name: Run tests on documentation examples id: pytest @@ -87,10 +89,12 @@ jobs: terraform_version: ${{ env.TF_VERSION }} terraform_wrapper: false + # avoid conflicts with user-installed providers on local machines - name: Pin provider versions run: | - sed -i 's/>=\(.*# tftest\)/=\1/g' default-versions.tf - find -name versions.tf -exec cp default-versions.tf {} \; + for f in $(find . -name versions.tf); do + sed -i 's/>=\(.*# tftest\)/=\1/g' $f; + done - name: Run tests environments id: pytest @@ -120,10 +124,12 @@ jobs: terraform_version: ${{ env.TF_VERSION }} terraform_wrapper: false + # avoid conflicts with user-installed providers on local machines - name: Pin provider versions run: | - sed -i 's/>=\(.*# tftest\)/=\1/g' default-versions.tf - find -name versions.tf -exec cp default-versions.tf {} \; + for f in $(find . -name versions.tf); do + sed -i 's/>=\(.*# tftest\)/=\1/g' $f; + done - name: Run tests modules id: pytest @@ -153,10 +159,12 @@ jobs: terraform_version: ${{ env.TF_VERSION }} terraform_wrapper: false + # avoid conflicts with user-installed providers on local machines - name: Pin provider versions run: | - sed -i 's/>=\(.*# tftest\)/=\1/g' default-versions.tf - find -name versions.tf -exec cp default-versions.tf {} \; + for f in $(find . -name versions.tf); do + sed -i 's/>=\(.*# tftest\)/=\1/g' $f; + done - name: Run tests on FAST stages id: pytest diff --git a/tests/conftest.py b/tests/conftest.py index 48498db553..a5ded0707f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -145,3 +145,8 @@ def run_apply(fixture_path=None, **tf_vars): return apply, output return run_apply + + +@pytest.fixture +def basedir(): + return BASEDIR diff --git a/tests/fast/stages/s00_cicd/test_providers.py b/tests/fast/stages/s00_cicd/test_providers.py index f2b39e9126..e45c869e3d 100644 --- a/tests/fast/stages/s00_cicd/test_providers.py +++ b/tests/fast/stages/s00_cicd/test_providers.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pathlib +import os ''' github = { source = "integrations/github" @@ -24,10 +24,11 @@ } ''' -# def test_providers(): -# "Test providers file." -# p = pathlib.Path(__file__).parents[4] -# with (p / 'fast/stages/00-cicd/versions.tf').open() as f: -# data = f.read() -# assert 'integrations/github' in data -# assert 'gitlabhq/gitlab' in data + +def test_providers(basedir): + "Test providers file." + p = os.path.join(basedir, 'fast/stages/00-cicd/versions.tf') + with open(p) as f: + data = f.read() + assert 'integrations/github' in data + assert 'gitlabhq/gitlab' in data