44# you may not use this file except in compliance with the License.
55# You may obtain a copy of the License at
66#
7- # https://www.apache.org/licenses/LICENSE-2.0
7+ # https://www.apache.org/licenses/LICENSE-2.0
88#
99# Unless required by applicable law or agreed to in writing, software
1010# distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,6 +25,13 @@ def plan_out(fixtures_dir):
2525 return tftest .TerraformPlanOutput (json .load (fp ))
2626
2727
28+ @pytest .fixture (scope = "module" )
29+ def plan_out_no_prior (fixtures_dir ):
30+ import json
31+ with open ('%s/plan_output_no_prior.json' % fixtures_dir ) as fp :
32+ return tftest .TerraformPlanOutput (json .load (fp ))
33+
34+
2835def test_output_attributes (plan_out ):
2936 assert plan_out .format_version == "0.1"
3037 assert plan_out .terraform_version == "0.12.6"
@@ -86,3 +93,15 @@ def test_plan_stdout(fixtures_dir):
8693 tf = tftest .TerraformTest ('plan_no_resource_changes' , fixtures_dir )
8794 result = tf .plan (output = False )
8895 assert 'just_an_output = "Hello, plan!"' in result
96+
97+
98+ def test_plan_prior_state (plan_out ):
99+ prior_resources = plan_out .prior_resources
100+ assert len (prior_resources ) == 1
101+ assert prior_resources ['data.google_client_config.current' ]['type' ] == 'google_client_config'
102+ assert prior_resources ['data.google_client_config.current' ]['values' ]['description' ] == 'foo-value'
103+
104+
105+ def test_plan_no_prior_state (plan_out_no_prior ):
106+ prior_resources = plan_out_no_prior .prior_resources
107+ assert not prior_resources
0 commit comments