[WIP] Factory change removing abstract Vm#23608
[WIP] Factory change removing abstract Vm#23608kbrock wants to merge 1 commit intoManageIQ:masterfrom
Conversation
|
@agrare Thoughts here? |
| @@ -1,5 +1,5 @@ | |||
| FactoryBot.define do | |||
| factory :vm_or_template do | |||
| factory :vm_or_template, :class => "ManageIQ::Providers::Vmware::InfraManager::Vm" do | |||
There was a problem hiding this comment.
we have a separate factory vm_vmware which already does this.
There was a problem hiding this comment.
I was thinking that vm, vm_or_template, and vm_vmware would be interchangeable. They instantiate a vm.
Or maybe they pick a random child? (though we need consistency with that and the corresponding ems)
I do like when tests link to "any vm or template".
But I don't think we should instantiate that class.
I couldn't declare the parent of vm to be vm_vmware since we needed it to still flow up to vm_or_template.
There was a problem hiding this comment.
VmOrTemplate is a real class, not something abstract.
I don't think we should change factory :vm_or_template to return Vmware::InfraManager::Vm, I think we should change any specs that use FactoryBot.build(:vm_or_template) if that isn't what they really mean.
There was a problem hiding this comment.
Well, the tests don't care.
But that doesn't mean we should store :type => 'VmOrTemplate' in the database.
Don't create entries in the database with parent abstract classes Avoid Infra or Vm -- instead do a vendor specific vm (would have preferred to use the dummy provider)
0fd2b69 to
d1d8c1e
Compare
|
@agrare Yea, so thinking we want to put in a Providers::Dummy::Vm here or something. Thinking of doing this across all STI models - especially Does Dummy have both an Infra and a Container aspect? (Do we need Cloud too?) Interestingly, this was the main issue with #23604 - once we stated that |
|
Out of band with @agrare
moved TODO to top comment |
|
WIP: have a plan. probably a few PRs. After that, this should be good |
These don't bother me as much if the operation being tested is generic enough that we don't need a subclass. For example, things like verifying column length validations - we don't need a specific VM to verify something like that. |
|
Checked commit kbrock@d1d8c1e with ruby 3.1.7, rubocop 1.56.3, haml-lint 0.64.0, and yamllint spec/factories/vm_or_template.rb
|
|
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
Does it make sense to not use Vm/VmOrTemplate abstract classes for out tests?
Maybe we need to push/flush out dummy providers first?
Why
I was working on #23604 and was getting weird errors around a
Vmin the database. It seemed odd to me that we would do this.TODO:
factory :vm_infratoDummy::Vm:vm_or_templateand:vmto:vm_dummyfactory :vm*to only allow leafs. (Thinking we want to allow:vm_infra). This is similar to ems factories