Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write operations can't be chained #8

Open
richardszalay opened this issue Jun 25, 2017 · 0 comments
Open

Write operations can't be chained #8

richardszalay opened this issue Jun 25, 2017 · 0 comments

Comments

@richardszalay
Copy link
Owner

Because writes to the hosts file aren't committed until EndProcessing, piping together write operations fail. For example, the following test fails Set re-reads the hosts file and doesn't find the added entry (because it hasn't been saved yet). It would also cause undefined side effects as both cmdlets would attempt to save their copy of the hosts file.

I'm not sure the best way to resolve this problem (particularly since it's quite unlikely that someone would pipe the write operations together), but I thought it was worth documenting.

Describe "Add-HostEntry" {
    Context "Piping into Set" {
        BeforeEach {
            Add-TestHostEntry -Name "hostname" -Loopback -HostsPath $hostsFile | `
                Set-TestHostEntry -Address "127.0.0.2" -HostsPath $hostsFile
        }

        It "Should update new entry" {
            $results = Get-TestHostEntry hostname -HostsPath $hostsFile

            $results.Length | Should be 1
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant