【问题标题】:How to test readonly property of Puppet type如何测试 Puppet 类型的只读属性
【发布时间】:2015-02-09 15:14:26
【问题描述】:

我有这样定义的 Puppet 类型:

Puppet::Type.newtype(:my_type) do
  newproperty(:id, :readonly => true) do
    desc "Some id."
  end
end

我想问一下如何在 rspecs 中测试属性 :id 是只读的?

describe Puppet::Type.type(:netapp_e_volume) do
  it 'should have readonly :id attribute' do
    # this part I don't have
  end
end

【问题讨论】:

  • 会发生这种情况吗?在 Puppet 的核心类型中使用这种语法似乎没有先例(现在?)
  • 出自《Puppet Types and Providers》一书:“某些属性,例如UUID,可以从系统中查询,但不能更新。这些属性可以实现为只读属性,以便puppet资源在检查系统时仍然返回它们的值。”
  • 我知道这样的事情曾经被记录在案,但我在源代码中没有发现任何迹象表明a)这是可能的或易于实现的,b)您使用的语法在全部。所以我想真正的问题是如何首先将属性标记为只读,我现在没有答案。

标签: ruby rspec puppet ruby-1.8.7 rspec3


【解决方案1】:

截至 2016 年 4 月,根据此 Puppet Jira Ticket,这仍然是不可能的

https://tickets.puppetlabs.com/browse/PUP-5624

票证仍处于未解决状态

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-03
    • 2018-09-13
    • 2016-03-24
    • 2011-04-04
    相关资源
    最近更新 更多