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

(MODULES-3037) Acceptance tests - ChocolateySource #21

Merged
merged 1 commit into from
Jun 1, 2016

Conversation

ThoughtCrhyme
Copy link

Adds negative tests for:

  • applying a bad manifest
  • trying to set a password with no user name
  • trying to set a uersname with no password

Adds test for overwriting the source location. The default chocolatey behavior of overwriting source with the name
of a resource should be discussed.

Adds negative tests for:
* applying a bad manifest
* trying to set a password with no user name
* trying to set a uersname with no password

Adds test for overwriting the source location. The default chocolatey behavior of overwriting source with the name
of a resource should be discussed.
step 'Apply Manifest'
apply_manifest(chocolatey_src, :catch_failures => true) do
step 'Verify Result'
assert_match(/Notice: \/Stage\[main\]\/Main\/Chocolateysource\[chocolatey\]\/location: location changed 'https:\/\/chocolatey.org\/api\/v2\/' to 'chocolatey'/, stdout, "stdout did not match expected")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ferventcoder @Iristyle The behavior here of declaring a chcolateysource with no location and having the chocolatey.config location overwritten with the resource name seems bad. Why would you ever want that to happen? I believe it should just throw an error.

Ex: before the apply the source looks like <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" priority="0" />

After it loos like <source id="chocolatey" value="chocolatey" disabled="false" priority="0" />

Copy link

@ferventcoder ferventcoder Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to allow for:

chocolateysource { 'c:\\packages': }

Copy link

@Iristyle Iristyle Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I understand that bit. The path as title makes sense (and we saw that looking through the code).

However, if you already have a choco source defined that is not a UNC path, HTTP uri or local path on disk... then I don't think it makes sense to do something like this:

chocolateysource { 'foo': }

If a source named foo exists, it sets location to foo, which is almost certainly not what you wanted - it obliterates the location with something unusable.

If you really wanted to remove foo, you would want this instead:

chocolateysource { 'foo': 
  ensure => absent
}

Further / related... would it ever make sense for a user to do this:

chocolateysource { 'c:\\packages':
  location => 'https://foo.com/'
}

That's allowable as far as I can tell, but arguably doesn't make much sense, right? If that doesn't make sense, then maybe you should never modify an existing named source, when the puppet resource doesn't explicitly set a location - but you'd want to warn / notify the user probably when the title isn't a location.

Copy link

@ferventcoder ferventcoder Jun 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would someone define a resource as chocolateysource { 'foo': } like that? There are other T&P I could make the same argument on. :D

And to remove foo, I agree that's how you do it, nobody said it would be done any other way (unless I missed something).

And the third, if you wanted to have a useless name that didn't define the location very well - to put it bluntly, that's on you.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking at this with a grain of what a customer would realistically do.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the behavior of defaulting location to the name. I just took a look at yumrepo and it keeps them explicit and separate.

@ferventcoder
Copy link

This all passed locally.

@ferventcoder ferventcoder merged commit 8870a0e into puppetlabs:master Jun 1, 2016
ThoughtCrhyme pushed a commit to ThoughtCrhyme/puppetlabs-chocolatey that referenced this pull request Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants