aboutsummaryrefslogtreecommitdiff
path: root/tests/rep-add.testscript
blob: b57eb6870ecfeb6f3efa6386238e7cfe6f035ddb (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# file      : tests/rep-add.testscript
# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include common.testscript config.testscript

rep_list += -d cfg

: location
:
{
  +$clone_cfg

  : none
  :
  $* 2>>EOE != 0
  error: repository location argument expected
    info: run 'bpkg help rep-add' for more information
  EOE

  : empty
  :
  {
    $clone_cfg;

    $* '' 2>>EOE != 0
    error: invalid repository location '': empty URL
    EOE
  }

  : unknown-type
  :
  $* 'repo' --type unknown 2>>EOE != 0
  error: invalid value 'unknown' for option '--type'
  EOE

  : no-version
  :
  {
    $clone_cfg;

    $* 'stable' 2>>/~%EOE% != 0
    %error: invalid pkg repository location '.+/no-version/stable': missing repository version%
      info: consider using --type to specify repository type
    EOE
  }

  : git-invalid-fragment
  :
  {
    $clone_cfg;

    $* 'git://example.org/repo#' 2>>EOE != 0
    error: invalid git repository location 'git://example.org/repo#': missing refname or commit id for git repository
    EOE
  }

  : pkg-git-scheme
  :
  {
    $clone_cfg;

    $* 'git://example.org/repo' --type pkg 2>>EOE != 0
    error: invalid pkg repository location 'git://example.org/repo': unsupported scheme for pkg repository
    EOE
  }

  : invalid-path
  :
  {
    s="../../../../../../../../../../../../../../../../../../../../../../../"
    s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"

    $clone_cfg;

    $* "$s" 2>>~%EOE% != 0
    %error: invalid repository path '.+/': invalid filesystem path%
    EOE
  }

  : type-detection
  :
  {
    +$clone_cfg

    : git-scheme
    :
    $clone_cfg;
    $* 'git://example.org/repo#master' 2>>EOE
      added git:example.org/repo#master
      EOE

    : http-git
    :
    $clone_cfg;
    $* 'http://example.org/repo.git#master' 2>>EOE
      added git:example.org/repo#master
      EOE

    : http-pkg
    :
    $clone_cfg;
    $* 'http://example.org/1/repo' 2>>EOE
      added pkg:example.org/repo
      EOE

    : file-git
    :
    $clone_cfg && mkdir -p repo/.git;

    $* 'repo' 2>>/~%EOE%
      %added git:.+/repo%
      EOE

    : file-pkg
    :
    $clone_cfg;

    $* '1/repo' 2>>/~%EOE%
      %added .+/repo%
      EOE
  }
}

: relative-path
:
{
  $clone_cfg;

  $* ./1/bar/stable 2>>/~%EOE%;
    %added pkg:.+/relative-path/bar/stable%
    EOE

  $* ./1/../1/bar/stable 2>>/~%EOE%
    %unchanged pkg:.+/relative-path/bar/stable%
    EOE
}

: absolute-path
:
{
  $clone_cfg;

  $* $~/1/foo/stable 2>>/~%EOE%;
    %added pkg:.+/absolute-path/foo/stable%
    EOE

  $* $~/1/../1/foo/stable 2>>/~%EOE%
    %unchanged pkg:.+/absolute-path/foo/stable%
    EOE
}

: remote-url
:
{
  +$clone_cfg

  : pkg
  :
  $clone_cfg;

  $* 'http://pkg.example.org/1/testing' 2>>EOE;
    added pkg:example.org/testing
    EOE

  $* 'https://www.example.org/1/testing' 2>>EOE;
    updated pkg:example.org/testing
    EOE

  $rep_list >>EOO
    pkg:example.org/testing https://www.example.org/1/testing
    EOO

  : git
  :
  $clone_cfg;

  $* 'git://example.org/testing.git#master' 2>>~%EOE%;
    %added git:example.org/testing#master%
    EOE

  $* 'https://www.example.org/testing.git#master' 2>>EOE;
    updated git:example.org/testing#master
    EOE

  $rep_list >>EOO
    git:example.org/testing#master https://www.example.org/testing.git#master
    EOO
}

: multiple-locations
:
{
  $clone_cfg;

  $* 'http://pkg.example.org/1/alpha' 'http://pkg.example.org/1/beta' 2>>EOE;
    added pkg:example.org/alpha
    added pkg:example.org/beta
    EOE

  $rep_list >>EOO
    pkg:example.org/alpha http://pkg.example.org/1/alpha
    pkg:example.org/beta http://pkg.example.org/1/beta
    EOO
}