summaryrefslogtreecommitdiffstats
path: root/puppet/modules/registry/tests/value.pp
blob: a5d7acca394bff3e99490625098e8bee3326bd78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# mock the registry class and script file here,
# otherwise the test may fail if the real script exists,
# is owned by SYSTEM, and we are running the test as a
# normal user
class registry {
    $script = "C:\\fakescript"
    if $::operatingsystem == 'windows' {
        file { $script: }
    }
}

include registry

# not supported outside of Windows
if $::operatingsystem == 'windows' {
    # expected default view args
    $view_args = $::architecture ? {
        x64 => '-view64',
        default => '',
    }

    registry::value { "screensaver off":
        key => 'HKU\someuser',
        value => 'screensaver',
        data => '0',
        ensure => present,
    }
    selftest::expect { "first key created":
        output => "Exec\\[.*fakescript write $view_args -path \"HKU\\\\someuser\\\\screensaver\"",
    }

    registry::value { "some HKLM key":
        key => 'HKLM\thing1\thing2',
        value => 'thing3',
        type => 'expand',
        view => '32',
        ensure => present,
    }
    selftest::expect { "second key created":
        output => "Exec\\[.*fakescript write -view32 -path \"HKLM\\\\thing1\\\\thing2\\\\thing3\".*-type \"REG_EXPAND_SZ\"",
    }

    registry::value { "other HKLM key":
        key => 'HKLM\thing1\thing2',
        value => 'thing4',
        ensure => absent,
    }

    selftest::expect_no_warnings { "no warnings from registry::value": }
}