Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b387486

Browse files
committedMar 10, 2023
Add a Stdlib::File::Content type alias
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.
1 parent 15fb857 commit b387486

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
 
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# coding: utf-8
2+
# frozen_string_literal: true
3+
4+
require 'spec_helper'
5+
6+
describe 'Stdlib::Filemode' do
7+
describe 'valid content' do
8+
[
9+
'',
10+
'abc',
11+
sensitive('secret'),
12+
# TODO: test Deferred?
13+
].each do |value|
14+
describe value.inspect do
15+
it { is_expected.to allow_value(value) }
16+
end
17+
end
18+
19+
context 'with garbage inputs' do
20+
[
21+
nil,
22+
1,
23+
].each do |value|
24+
describe value.inspect do
25+
it { is_expected.not_to allow_value(value) }
26+
end
27+
end
28+
end
29+
end

‎types/file/content.pp

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# @summary Validate a file content attribute
2+
type Stdlib::File::Content = Variant[String, Sensitive[String], Deferred[String]]

0 commit comments

Comments
 (0)
Please sign in to comment.