Skip to content

Commit

Permalink
Add a Stdlib::File::Content type alias
Browse files Browse the repository at this point in the history
This should describe the valid input for content. It doesn't list Undef
so module authors can enforce content is set. If it's optional,
Optional[Stdlib::File::Content] is easy to use.
  • Loading branch information
ekohl committed Mar 10, 2023
1 parent 15fb857 commit b387486
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/type_aliases/file_content_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# coding: utf-8
# frozen_string_literal: true

require 'spec_helper'

describe 'Stdlib::Filemode' do
describe 'valid content' do
[
'',
'abc',
sensitive('secret'),
# TODO: test Deferred?
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
end
end

context 'with garbage inputs' do
[
nil,
1,
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
end
end
end
end
2 changes: 2 additions & 0 deletions types/file/content.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @summary Validate a file content attribute
type Stdlib::File::Content = Variant[String, Sensitive[String], Deferred[String]]

0 comments on commit b387486

Please sign in to comment.