github.com/tooploox/oya@v0.0.21-0.20230524103240-1cda1861aad6/features/require.feature (about)

     1  Feature: Dependency management
     2  
     3  Background:
     4     Given I'm in project dir
     5  
     6  Scenario: Get a specific pack version
     7    Given file ./Oyafile containing
     8      """
     9      Project: project
    10      """
    11    When I run "oya get github.com/tooploox/oya-fixtures@v1.0.0"
    12    Then the command succeeds
    13    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.0.0/Oyafile exists
    14    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.0.0/VERSION contains
    15      """
    16      1.0.0
    17  
    18      """
    19    And file ./Oyafile contains
    20      """
    21      Project: project
    22      Require:
    23        github.com/tooploox/oya-fixtures: v1.0.0
    24  
    25      """
    26  
    27  Scenario: Get the latest pack version
    28    Given file ./Oyafile containing
    29      """
    30      Project: project
    31      """
    32    When I run "oya get github.com/tooploox/oya-fixtures"
    33    Then the command succeeds
    34    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.1.0/Oyafile exists
    35    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.1.0/VERSION contains
    36      """
    37      1.1.0
    38  
    39      """
    40    And file ./Oyafile contains
    41      """
    42      Project: project
    43      Require:
    44        github.com/tooploox/oya-fixtures: v1.1.0
    45  
    46      """
    47  
    48  Scenario: Get pack from a multi-pack repo
    49    Given file ./Oyafile containing
    50      """
    51      Project: project
    52      """
    53    When I run "oya get github.com/tooploox/oya-fixtures/pack1@v1.1.1"
    54    Then the command succeeds
    55    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
    56    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
    57      """
    58      1.1.1
    59  
    60      """
    61    And file ./Oyafile contains
    62      """
    63      Project: project
    64      Require:
    65        github.com/tooploox/oya-fixtures/pack1: v1.1.1
    66  
    67      """
    68  
    69  Scenario: Fetch only the package, not the entire repo
    70    Given file ./Oyafile containing
    71      """
    72      Project: project
    73      """
    74    When I run "oya get github.com/tooploox/oya-fixtures/pack1@v1.1.1"
    75    Then the command succeeds
    76    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.0/Oyafile does not exist
    77    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.0/VERSION does not exist
    78  
    79  Scenario: Require pack
    80    Given file ./Oyafile containing
    81      """
    82      Project: project
    83      Require:
    84        github.com/tooploox/oya-fixtures: v1.0.0
    85      foo: echo "bar"
    86      """
    87    When I run "oya run foo"
    88    Then the command succeeds
    89    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.0.0/Oyafile exists
    90    And file ./.oya/packs/github.com/tooploox/oya-fixtures@v1.0.0/VERSION contains
    91      """
    92      1.0.0
    93  
    94      """
    95  
    96  Scenario: Require pack from multi-pack repo
    97    Given file ./Oyafile containing
    98      """
    99      Project: project
   100      Require:
   101        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   102      foo: echo "bar"
   103      """
   104    When I run "oya run foo"
   105    Then the command succeeds
   106    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/Oyafile exists
   107    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/VERSION contains
   108      """
   109      1.0.0
   110  
   111      """
   112  
   113  Scenario: Require two packs from multi-pack repo
   114    Given file ./Oyafile containing
   115      """
   116      Project: project
   117      Require:
   118        github.com/tooploox/oya-fixtures/pack1: v1.1.1
   119        github.com/tooploox/oya-fixtures/pack2: v1.1.2
   120      foo: echo "bar"
   121      """
   122    When I run "oya run foo"
   123    Then the command succeeds
   124    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   125    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   126      """
   127      1.1.1
   128  
   129      """
   130    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/Oyafile exists
   131    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/VERSION contains
   132      """
   133      1.1.2
   134  
   135      """
   136  
   137  Scenario: Get command does not upgrade pack by default
   138    Given file ./Oyafile containing
   139      """
   140      Project: project
   141      Require:
   142        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   143        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   144      foo: echo "bar"
   145      """
   146    When I run "oya run foo"
   147    And I run "oya get github.com/tooploox/oya-fixtures/pack1"
   148    Then the command succeeds
   149    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/Oyafile exists
   150    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/VERSION contains
   151      """
   152      1.0.0
   153  
   154      """
   155    And file ./Oyafile contains
   156      """
   157      Project: project
   158      Require:
   159        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   160        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   161      foo: echo "bar"
   162      """
   163  
   164  Scenario: Upgrade single pack using get command
   165    Given file ./Oyafile containing
   166      """
   167      Project: project
   168      Require:
   169        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   170        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   171      foo: echo "bar"
   172      """
   173    When I run "oya run foo"
   174    And I run "oya get -u github.com/tooploox/oya-fixtures/pack1"
   175    Then the command succeeds
   176    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   177    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   178      """
   179      1.1.1
   180  
   181      """
   182    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.0.0/Oyafile exists
   183    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.0.0/VERSION contains
   184      """
   185      1.0.0
   186  
   187      """
   188    And file ./Oyafile contains
   189      """
   190      Project: project
   191      Require:
   192        github.com/tooploox/oya-fixtures/pack1: v1.1.1
   193        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   194      foo: echo "bar"
   195  
   196      """
   197  
   198  Scenario: Upgrade pack by editing the Require section
   199    Given file ./Oyafile containing
   200      """
   201      Project: project
   202      Require:
   203        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   204        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   205      foo: echo "bar"
   206      """
   207    When I run "oya run foo"
   208    And I modify file ./Oyafile to contain
   209      """
   210      Project: project
   211      Require:
   212        github.com/tooploox/oya-fixtures/pack1: v1.1.1
   213        github.com/tooploox/oya-fixtures/pack2: v1.0.0
   214      foo: echo "bar"
   215      """
   216    And I run "oya run foo"
   217    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   218    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   219      """
   220      1.1.1
   221  
   222      """
   223  
   224  Scenario: Generate requires from imports
   225    Given file ./Oyafile containing
   226      """
   227      Project: project
   228      Import:
   229        pack1: github.com/tooploox/oya-fixtures/pack1
   230      foo: echo "bar"
   231      """
   232    And file ./subdir/Oyafile containing
   233      """
   234      Import:
   235        pack2: github.com/tooploox/oya-fixtures/pack2
   236      """
   237    When I run "oya run foo"
   238    Then the command succeeds
   239    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   240    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   241      """
   242      1.1.1
   243  
   244      """
   245    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/Oyafile exists
   246    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/VERSION contains
   247      """
   248      1.1.2
   249  
   250      """
   251    And file ./Oyafile contains
   252      """
   253      Project: project
   254      Require:
   255        github.com/tooploox/oya-fixtures/pack2: v1.1.2
   256        github.com/tooploox/oya-fixtures/pack1: v1.1.1
   257      Import:
   258        pack1: github.com/tooploox/oya-fixtures/pack1
   259      foo: echo "bar"
   260  
   261      """
   262  
   263  Scenario: Preserve versions when generating requires from imports
   264    Given file ./Oyafile containing
   265      """
   266      Project: project
   267      Import:
   268        pack1: github.com/tooploox/oya-fixtures/pack1
   269      Require:
   270        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   271      foo: echo "bar"
   272      """
   273    And file ./subdir/Oyafile containing
   274      """
   275      Import:
   276        pack2: github.com/tooploox/oya-fixtures/pack2
   277      """
   278    When I run "oya run foo"
   279    Then the command succeeds
   280    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/Oyafile exists
   281    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.0.0/VERSION contains
   282      """
   283      1.0.0
   284  
   285      """
   286    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/Oyafile exists
   287    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack2@v1.1.2/VERSION contains
   288      """
   289      1.1.2
   290  
   291      """
   292    And file ./Oyafile contains
   293      """
   294      Project: project
   295      Import:
   296        pack1: github.com/tooploox/oya-fixtures/pack1
   297      Require:
   298        github.com/tooploox/oya-fixtures/pack2: v1.1.2
   299        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   300      foo: echo "bar"
   301  
   302      """
   303  
   304  Scenario: Indirect requirements are downloaded
   305    Given file ./Oyafile containing
   306      """
   307      Project: project
   308      Require:
   309        github.com/tooploox/oya-fixtures/pack3: v1.0.0
   310      foo: echo "bar"
   311      """
   312    When I run "oya run foo"
   313    Then the command succeeds
   314    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack3@v1.0.0/Oyafile contains
   315      """
   316      Project: github.com/tooploox/oya-fixtures/pack3
   317  
   318      Require:
   319        github.com/tooploox/oya-fixtures/pack1: v1.1.1
   320  
   321      version: |
   322        cat ${Oya[BasePath]}/VERSION
   323  
   324      """
   325    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   326    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   327      """
   328      1.1.1
   329  
   330      """
   331  
   332  Scenario: Indirectly required higher version
   333    Given file ./Oyafile containing
   334      """
   335      Project: project
   336      Require:
   337        github.com/tooploox/oya-fixtures/pack3: v1.0.0  # Requires pack1@v1.1.1
   338        github.com/tooploox/oya-fixtures/pack1: v1.0.0
   339  
   340      Import:
   341        pack1: github.com/tooploox/oya-fixtures/pack1
   342      """
   343    When I run "oya run pack1.version"
   344    Then the command succeeds
   345    And the command outputs
   346      """
   347      1.1.1
   348  
   349      """
   350    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/Oyafile exists
   351    And file ./.oya/packs/github.com/tooploox/oya-fixtures/pack1@v1.1.1/VERSION contains
   352      """
   353      1.1.1
   354  
   355      """
   356  
   357  Scenario: Error for Require in non-root Oyafile
   358    Given file ./Oyafile containing
   359      """
   360      Project: project
   361      """
   362    And file ./subdir/Oyafile containing
   363      """
   364      Require:
   365        github.com/tooploox/oya-fixtures/pack3: v1.0.0  # Requires pack1@v1.1.1
   366      """
   367    When I'm in the subdir dir
   368    And I run "oya tasks"
   369    Then the command fails with error matching
   370      """
   371      .*unexpected Require directive.*
   372      """