aboutsummaryrefslogtreecommitdiff
path: root/tests/rep-add.test
blob: 4e203ccbca151d032970db53770979139af0606a (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
# file      : tests/rep-add.test
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : MIT; see accompanying LICENSE file

.include common.test config.test

: location
:
{
  +$clone_cfg

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

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

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

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

  : git-no-branch
  :
  $* 'git://example.org/repo' 2>>EOE != 0
  error: invalid git repository location 'git://example.org/repo': missing branch/tag for git repository
  EOE

  : bpkg-git-scheme
  :
  $* 'git://example.org/repo' --type bpkg 2>>EOE != 0
  error: invalid bpkg repository location 'git://example.org/repo': unsupported scheme for bpkg 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"
    $* "$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 repository git:example.org/repo
      EOE

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

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

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

    $* 'repo' 2>>~%EOE% != 0
      %error: invalid git repository location '.+repo': missing branch/tag for git repository%
      EOE

    : file-bpkg
    :
    $clone_cfg;

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

: relative-path
:
{
  $clone_cfg;

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

  $* ./1/../1/bar/stable 2>>/~%EOE% != 0
    %error: .+/relative-path/bar/stable is already a repository of this configuration%
    EOE
}

: absolute-path
:
{
  $clone_cfg;

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

  $* $~/1/../1/foo/stable 2>>/~%EOE% != 0
    %error: .+/absolute-path/foo/stable is already a repository of this configuration%
    EOE
}

: remote-url
:
{
  $clone_cfg;

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

  $* 'https://www.example.org/1/testing' 2>>~%EOE% != 0
    %error: bpkg:example.org/testing is already a repository of this configuration%
    EOE
}