features/install_command.feature in berkshelf-2.0.18 vs features/install_command.feature in berkshelf-3.0.0.beta1

- old
+ new

@@ -1,452 +1,381 @@ Feature: install cookbooks from a Berksfile As a user with a Berksfile - I want to be able to run knife berkshelf install to install my cookbooks - So that I don't have to download my cookbooks and their dependencies manually + I want a command to install the cookbooks defined in my Berksfile and their recursive dependencies + So I don't have to download those cookbooks and their all of their dependencies manually - Scenario: installing a Berksfile that contains a source with a default location + Background: + Given the Berkshelf API server's cache is empty + And the Chef Server is empty + And the cookbook store is empty + + Scenario: installing the version that best satisfies our demand Given I write to "Berksfile" with: """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0' + source "http://localhost:26210" + + cookbook 'berkshelf' """ + And the Chef Server has cookbooks: + | berkshelf | 1.0.0 | + | berkshelf | 2.0.0 | + And the Berkshelf API server cache is up to date When I successfully run `berks install` - Then the cookbook store should have the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And the output should contain: + Then the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks' + Installing berkshelf (2.0.0) """ - And the exit status should be 0 + And the cookbook store should have the cookbooks: + | berkshelf | 2.0.0 | - Scenario: installing a Berksfile that contains the cookbook explicitly desired by a source - Given the cookbook store has the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And I write to "Berksfile" with: + Scenario: installing an explicit version demand + Given I write to "Berksfile" with: """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0' + source "http://localhost:26210" + + cookbook 'berkshelf', '1.0.0' """ + And the Chef Server has cookbooks: + | berkshelf | 1.0.0 | + | berkshelf | 2.0.0 | + And the Berkshelf API server cache is up to date When I successfully run `berks install` Then the output should contain: """ - Using berkshelf-cookbook-fixture (1.0.0) + Installing berkshelf (1.0.0) """ - And the exit status should be 0 + And the cookbook store should have the cookbooks: + | berkshelf | 1.0.0 | - Scenario: installing a Berksfile that has multiple cookbooks in different groups - Given the cookbook store has the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And I write to "Berksfile" with: + Scenario: installing demands from all groups + Given I write to "Berksfile" with: """ - group :a do - cookbook 'berkshelf-cookbook-fixture', '1.0.0' + source "http://localhost:26210" + + group :one do + cookbook 'ruby' end - group :b do - cookbook 'berkshelf-cookbook-fixture', '1.0.0' + group :two do + cookbook 'elixir' end """ + And the Chef Server has cookbooks: + | ruby | 1.0.0 | + | elixir | 1.0.0 | + And the Berkshelf API server cache is up to date When I successfully run `berks install` - Then the output should contain "Using berkshelf-cookbook-fixture (1.0.0)" - And the exit status should be 0 + Then the output should contain: + """ + Installing ruby (1.0.0) + Installing elixir (1.0.0) + """ + And the cookbook store should have the cookbooks: + | ruby | 1.0.0 | + | elixir | 1.0.0 | - Scenario: installing a Berksfile that contains a source with dependencies, all of which already have been installed - Given the cookbook store contains a cookbook "berkshelf-cookbook-fixture" "1.0.0" with dependencies: + Scenario: installing a demand that has already been installed + Given I write to "Berksfile" with: + """ + source "http://localhost:26210" + + cookbook 'berkshelf-cookbook-fixture', github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'deps' + """ + And the cookbook store contains a cookbook "berkshelf" "1.0.0" with dependencies: | hostsfile | = 1.0.1 | And the cookbook store has the cookbooks: | hostsfile | 1.0.1 | - And I write to "Berksfile" with: - """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0', github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'deps' - """ + And the Berkshelf API server cache is up to date When I successfully run `berks install` Then the output should contain: """ Using hostsfile (1.0.1) """ - And the exit status should be 0 - Scenario: installing a Berksfile that contains a path location - Given a Berksfile with path location sources to fixtures: - | example_cookbook | example_cookbook-0.5.0 | + Scenario: installing a demand from a path location + Given I write to "Berksfile" with: + """ + source "http://localhost:26210" + + cookbook 'example_cookbook', path: '../../spec/fixtures/cookbooks/example_cookbook-0.5.0' + """ + And the Berkshelf API server cache is up to date When I successfully run `berks install` Then the output should contain: """ - Using example_cookbook (0.5.0) at ' + Using example_cookbook (0.5.0) path: ' """ - And the exit status should be 0 Scenario: installing a Berksfile from a remote directory that contains a path location Given I write to "tmp_berks/Berksfile" with: """ + source "http://localhost:26210" + cookbook 'example_cookbook', path: '../../../spec/fixtures/cookbooks/example_cookbook-0.5.0' """ When I successfully run `berks install -b ./tmp_berks/Berksfile` Then the output should contain: """ - Using example_cookbook (0.5.0) at ' + Using example_cookbook (0.5.0) path: ' """ - And the exit status should be 0 - Scenario: installing a Berksfile that contains a Git location + Scenario: installing a demand from a Git location Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git" """ When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: + Then the cookbook store should have the git cookbooks: | berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc | And the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'master' + Fetching 'berkshelf-cookbook-fixture' from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'master' + building universe... + Using berkshelf-cookbook-fixture (1.0.0) git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'master' """ - And the exit status should be 0 - Scenario: installing a Berksfile that contains a Git location that has already been downloaded + Scenario: installing a demand from a Git location that has already been installed Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git" """ - And the cookbook store has the cookbooks installed by git: + And the cookbook store has the git cookbooks: | berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc | - And I successfully run `berks install` When I successfully run `berks install` - Then the exit status should be 0 + Then the output should contain: + """ + Using berkshelf-cookbook-fixture (1.0.0) git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'master' + """ Scenario: installing a Berksfile that contains a Git location with a rel Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'rel', rel: 'cookbooks/berkshelf-cookbook-fixture' """ When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: + Then the cookbook store should have the git cookbooks: | berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a | And the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) + Fetching 'berkshelf-cookbook-fixture' from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'rel' over protocol: 'git' + building universe... + Using berkshelf-cookbook-fixture (1.0.0) github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'rel' over protocol: 'git' """ - And the exit status should be 0 - Scenario: installing a Berksfile that contains a Git location with a rel that has already been downloaded - Given I write to "Berksfile" with: - """ - site :opscode - cookbook 'berkshelf-cookbook-fixture', github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'rel', rel: 'cookbooks/berkshelf-cookbook-fixture' - """ - And the cookbook store has the cookbooks installed by git: - | berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a | - And I successfully run `berks install` - When I run `berks install` - Then the output should contain: - """ - Installing berkshelf-cookbook-fixture (1.0.0) - """ - And the exit status should be 0 - Scenario: installing a Berksfile that contains a Git location with a tag Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git", tag: "v0.2.0" """ When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: + Then the cookbook store should have the git cookbooks: | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee | And the output should contain: """ - Installing berkshelf-cookbook-fixture (0.2.0) from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v0.2.0' + Fetching 'berkshelf-cookbook-fixture' from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v0.2.0' + building universe... + Using berkshelf-cookbook-fixture (0.2.0) git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v0.2.0' at ref: '70a527e17d91f01f031204562460ad1c17f972ee' """ - And the exit status should be 0 Scenario: installing a Berksfile that contains a GitHub location Given I write to "Berksfile" with: """ - cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v0.2.0" - """ - When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: - | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee | - And the output should contain: - """ - Installing berkshelf-cookbook-fixture (0.2.0) from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v0.2.0' - """ - And the exit status should be 0 + source "http://localhost:26210" - Scenario: installing a Berksfile that contains a Github location and the default protocol - Given I write to "Berksfile" with: - """ cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v0.2.0" """ When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: + Then the cookbook store should have the git cookbooks: | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee | And the output should contain: """ - Installing berkshelf-cookbook-fixture (0.2.0) from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v0.2.0' over protocol: 'git' + Fetching 'berkshelf-cookbook-fixture' from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v0.2.0' over protocol: 'git' + building universe... + Using berkshelf-cookbook-fixture (0.2.0) github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v0.2.0' over protocol: 'git' """ - And the exit status should be 0 Scenario Outline: installing a Berksfile that contains a Github location and specific protocol Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v1.0.0", protocol: "<protocol>" """ When I successfully run `berks install` - Then the cookbook store should have the cookbooks installed by git: + Then the cookbook store should have the git cookbooks: | berkshelf-cookbook-fixture | 1.0.0 | b4f968c9001ad8de30f564a2107fab9cfa91f771 | And the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v1.0.0' over protocol: '<protocol>' + Fetching 'berkshelf-cookbook-fixture' from github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v1.0.0' over protocol: '<protocol>' + building universe... + Using berkshelf-cookbook-fixture (1.0.0) github: 'RiotGames/berkshelf-cookbook-fixture' with branch: 'v1.0.0' over protocol: '<protocol>' """ - And the exit status should be 0 Examples: | protocol | - # | ssh | # GitHub over ssh requires push authorization. Nonpushers will get a test failure here. | git | | https | Scenario: installing a Berksfile that contains a Github location and an unsupported protocol Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v0.2.0", protocol: "somethingabsurd" """ When I run `berks install` Then the output should contain: """ 'somethingabsurd' is not supported for the 'github' location key - please use 'git' instead """ - And the exit status should be 110 + And the exit status should be "InvalidGitURI" - Scenario: installing a Berksfile that contains an explicit site location - Given I write to "Berksfile" with: - """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0', site: 'http://cookbooks.opscode.com/api/v1/cookbooks' - """ - When I successfully run `berks install` - Then the cookbook store should have the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And the output should contain: - """ - Installing berkshelf-cookbook-fixture (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks' - """ - And the exit status should be 0 - Scenario: running install when current project is a cookbook and the 'metadata' is specified Given a cookbook named "sparkle_motion" And the cookbook "sparkle_motion" has the file "Berksfile" with: """ + source "http://localhost:26210" + metadata """ When I cd to "sparkle_motion" And I successfully run `berks install` - Then the stdout should contain exactly: + Then the output should contain: """ - Using sparkle_motion (0.0.0) from metadata - + Using sparkle_motion (0.0.0) """ - And the exit status should be 0 Scenario: running install when current project is a cookbook and the 'metadata' is specified with a path Given a cookbook named "fake" And I write to "Berksfile" with: """ + source "http://localhost:26210" + metadata path: './fake' """ When I successfully run `berks install` - Then the stdout should contain exactly: + Then the output should contain: """ - Using fake (0.0.0) from metadata at './fake' - + Using fake (0.0.0) """ - And the exit status should be 0 Scenario: running install with no Berksfile or Berksfile.lock - Given I do not have a Berksfile - And I do not have a Berksfile.lock When I run `berks install` Then the output should contain: """ - No Berksfile or Berksfile.lock found at ' + No Berksfile or Berksfile.lock found at: """ - And the CLI should exit with the status code for error "BerksfileNotFound" + And the exit status should be "BerksfileNotFound" Scenario: running install when the Cookbook is not found on the remote site Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook 'doesntexist' + cookbook 'other-failure' """ And I run `berks install` Then the output should contain: """ - Cookbook 'doesntexist' not found in any of the default locations + Unable to find a solution for demands: doesntexist (>= 0.0.0), other-failure (>= 0.0.0) """ - And the CLI should exit with the status code for error "CookbookNotFound" + And the exit status should be "NoSolutionError" Scenario: installing a Berksfile that has a Git location source with an invalid Git URI Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook 'nginx', git: '/something/on/disk' """ When I run `berks install` Then the output should contain: """ '/something/on/disk' is not a valid Git URI """ - And the CLI should exit with the status code for error "InvalidGitURI" + And the exit status should be "InvalidGitURI" Scenario: installing when there are sources with duplicate names defined in the same group Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook 'berkshelf-cookbook-fixture' cookbook 'berkshelf-cookbook-fixture' """ When I run `berks install` Then the output should contain: """ - Berksfile contains multiple sources named 'berkshelf-cookbook-fixture'. Use only one, or put them in different groups. + Berksfile contains multiple entries named 'berkshelf-cookbook-fixture'. Use only one, or put them in different groups. """ - And the CLI should exit with the status code for error "DuplicateSourceDefined" + And the exit status should be "DuplicateDependencyDefined" - Scenario: When a version constraint in the metadata exists, but does not satisfy - Given a cookbook named "fake" - And I write to "Berksfile" with: + Scenario: when a Git demand points to a branch that does not satisfy the version constraint + Given I write to "Berksfile" with: """ - site :opscode - cookbook 'fake', path: './fake' - """ - And the cookbook "fake" has the file "metadata.rb" with: - """ - name 'fake' - version '1.0.0' + source "http://localhost:26210" - depends 'berkshelf-cookbook-fixture', '~> 0.2.0' + cookbook "berkshelf-cookbook-fixture", "1.0.0", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git", tag: "v0.2.0" """ - And the cookbook store has the cookbooks: - | berkshelf-cookbook-fixture | 0.2.0 | - And I successfully run `berks install` - And the cookbook "fake" has the file "metadata.rb" with: - """ - name 'fake' - version '1.0.0' - - depends 'berkshelf-cookbook-fixture', '~> 1.0.0' - """ - When I successfully run `berks install` + When I run `berks install` Then the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) + Fetching 'berkshelf-cookbook-fixture' from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v0.2.0' + The cookbook downloaded for berkshelf-cookbook-fixture (= 1.0.0) did not satisfy the constraint. """ - And the cookbook store should have the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And the exit status should be 0 + And the exit status should be "CookbookValidationFailure" - Scenario: installing when a git source defines a branch that does not satisfy the version constraint + Scenario: when a Git demand is defined and a cookbook of the same name and version is already in the cookbook store Given I write to "Berksfile" with: """ - cookbook "berkshelf-cookbook-fixture", "= 1.0.0", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git", tag: "v0.2.0" - """ - When I run `berks install` - Then the output should match multiline: - """ - The cookbook downloaded from git: 'git://github\.com/RiotGames/berkshelf-cookbook-fixture\.git' with branch: 'v0\.2\.0' at ref: '.+': - berkshelf-cookbook-fixture \(.+\) + source "http://localhost:26210" - does not satisfy the version constraint: - berkshelf-cookbook-fixture \(= 1.0.0\) - - This occurs when the Chef Server has a cookbook with a missing/mis-matched version number in its `metadata.rb` - """ - And the CLI should exit with the status code for error "CookbookValidationFailure" - - Scenario: when a git location source is defined and a cookbook of the same name is already cached in the cookbook store - Given I write to "Berksfile" with: - """ cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git", tag: "v1.0.0" """ And the cookbook store has the cookbooks: | berkshelf-cookbook-fixture | 1.0.0 | When I successfully run `berks install` Then the output should contain: """ - Installing berkshelf-cookbook-fixture (1.0.0) from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v1.0.0' at ref: + Fetching 'berkshelf-cookbook-fixture' from git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v1.0.0' + building universe... + Using berkshelf-cookbook-fixture (1.0.0) git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git' with branch: 'v1.0.0' at ref: 'b4f968c9001ad8de30f564a2107fab9cfa91f771' """ - And the exit status should be 0 Scenario: with a cookbook definition containing an invalid option Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook "berkshelf-cookbook-fixture", whatisthis: "I don't even know", anotherwat: "isthat" """ When I run `berks install` Then the output should contain: """ - Invalid options for Cookbook Source: 'whatisthis', 'anotherwat'. + Invalid options for dependency: 'whatisthis', 'anotherwat'. """ - And the CLI should exit with the status code for error "InternalError" + And the exit status should be "InternalError" - @chef_server - Scenario: with a cookbook definition containing a chef_api source location - Given I write to "Berksfile" with: - """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0', chef_api: :config - """ - And the Chef server has cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - When I successfully run `berks install` - Then the output should contain: - """ - Installing berkshelf-cookbook-fixture (1.0.0) from chef_api: - """ - And the cookbook store should have the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And the exit status should be 0 - - Scenario: when the :site is not defined - Given I write to "Berksfile" with: - """ - cookbook 'berkshelf-cookbook-fixture', '1.0.0', site: nil - """ - When I successfully run `berks install` - Then the output should contain: - """ - Installing berkshelf-cookbook-fixture (1.0.0) from site: - """ - And the cookbook store should have the cookbooks: - | berkshelf-cookbook-fixture | 1.0.0 | - And the exit status should be 0 - - Scenario: with a chef_api source location specifying :config when a Berkshelf config is not found at the given path - Given I write to "Berksfile" with: - """ - cookbook 'berkshelf-cookbook-fixture', chef_api: :config - """ - When I run the install command with flags: - | -c /tmp/notthere.lol | - Then the output should contain: - """ - No Berkshelf config file found at: '/tmp/notthere.lol'! - """ - And the CLI should exit with the status code for error "ConfigNotFound" - Scenario: with a git error during download Given I write to "Berksfile" with: """ + source "http://localhost:26210" + cookbook 'berkshelf-cookbook-fixture', '1.0.0' cookbook "doesntexist", git: "git://github.com/asdjhfkljashflkjashfakljsf" """ When I run `berks install` Then the output should contain: """ - Failed to download 'doesntexist' from git: + Fetching 'doesntexist' from git: 'git://github.com/asdjhfkljashflkjashfakljsf' with branch: 'master' + An error occurred during Git execution: """ - And the CLI should exit with the status code for error "CookbookNotFound" - - Scenario: invalid site symbol - Given I write to "Berksfile" with: - """ - site :somethingabsurd - cookbook 'berkshelf-cookbook-fixture' - """ - When I run `berks install` - Then the output should contain: - """ - Unknown site shortname 'somethingabsurd' - supported shortnames are: - """ + And the exit status should be "GitError"