theonestack / cfhlspec

MIT License
0 stars 0 forks source link

cfhlspec initial direction #1

Closed Guslington closed 4 years ago

Guslington commented 4 years ago

@aaronwalker @toshke just started this project on the back of doing some rspec testing on some of the new templates such as vpc-v2 and thought it would be better with some custom rspec matchers.

It currently will compile and validate the test from either a cftest yaml file or pass in custom config directly to Cfhlspec

from yaml

@cftest = Cfhlspec::Cftest.new(name: 'default', template_name: 'asg-v2', yaml: "tests/default.test.yaml")

or directly

@cftest = Cfhlspec::Cftest.new(name: 'default', template_name: 'asg-v2', config: {key: 'value'})

once initialised the components need to be loaded

@cftest.load_component() 

then they can be compiled and validated by either performing the tests

it 'compiles' do
    expect(@cftest).to compile
end

it 'validates' do
    expect(@cftest).to validate
end

or in the before stage

@cftest.compile_component() 
@cftest.validate_component() 

Once compiled the compiled yaml is loaded into an OpenStruct and then the template test can be performed on the struct

let(:template) { @cftest.load_template()}

My next step is to implement conditions and outputs and then some deeper resource testing.

Some other ideas are to pass in a parameter value and based upon that value test an outcome for example if we had an environment mapping and based upon the environment parameter we could test what the mapping value would be. Even on conditions if the condition is true will it create the resource.

Any thoughts, ideas, comments?

toshke commented 4 years ago

Haven't been giving testing of highlander components too much of a thought lately, I think README covers most of the cases consumer would expect, only idea is to add check for type of the property value. E.g. Lambda timeout property needs be a number. overall It's great work, making infra code supply chain more mature 👍