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
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 François Joulaud <francois.joulaud@radiofrance.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
;;; Summary
;; Tests for guix/import/go.scm
(define-module (test-import-go)
#:use-module (guix import go)
#:use-module (guix base32)
;#:use-module (guix tests)
#:use-module (ice-9 iconv)
#:use-module (ice-9 match)
#:use-module (srfi srfi-64))
(define fixture-go-mod-simple
"module my/thing
go 1.12
require other/thing v1.0.2
require new/thing/v2 v2.3.4
exclude old/thing v1.2.3
replace bad/thing v1.4.5 => good/thing v1.4.5
")
(define fixture-go-mod-with-block
"module M
require (
A v1
B v1.0.0
C v1.0.0
D v1.2.3
E dev
)
exclude D v1.2.3
")
(define fixture-go-mod-complete
"module M
go 1.13
replace github.com/myname/myproject/myapi => ./api
replace github.com/mymname/myproject/thissdk => ../sdk
replace launchpad.net/gocheck => github.com/go-check/check v0.0.0-20140225173054-eb6ee6f84d0a
require (
github.com/user/project v1.1.11
github.com/user/project/sub/directory v1.1.12
bitbucket.org/user/project v1.11.20
bitbucket.org/user/project/sub/directory v1.11.21
launchpad.net/project v1.1.13
launchpad.net/project/series v1.1.14
launchpad.net/project/series/sub/directory v1.1.15
launchpad.net/~user/project/branch v1.1.16
launchpad.net/~user/project/branch/sub/directory v1.1.17
hub.jazz.net/git/user/project v1.1.18
hub.jazz.net/git/user/project/sub/directory v1.1.19
k8s.io/kubernetes/subproject v1.1.101
one.example.com/abitrary/repo v1.1.111
two.example.com/abitrary/repo v0.0.2
)
replace two.example.com/abitrary/repo => github.com/corp/arbitrary-repo v0.0.2
replace (
golang.org/x/sys => golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // pinned to release-branch.go1.13
golang.org/x/tools => golang.org/x/tools v0.0.0-20190821162956-65e3620a7ae7 // pinned to release-branch.go1.13
)
")
(test-begin "import go")
(test-equal "go-path-escape"
"github.com/!azure/!avere"
((@@ (guix import go) go-path-escape) "github.com/Azure/Avere"))
;; We define a function for all similar tests with different go.mod files
(define (testing-parse-mod name expected input)
(define (inf? p1 p2)
(string<? (car p1) (car p2)))
(let ((input-port (open-input-string input)))
(test-equal name
(sort expected inf?)
(sort
( (@@ (guix import go) parse-go.mod-port)
input-port)
inf?))))
(testing-parse-mod "parse-go.mod-simple"
'(("good/thing" . "v1.4.5")
("new/thing/v2" . "v2.3.4")
("other/thing" . "v1.0.2"))
fixture-go-mod-simple)
(testing-parse-mod "parse-go.mod-with-block"
'(("A" . "v1")
("B" . "v1.0.0")
("C" . "v1.0.0")
("D" . "v1.2.3")
("E" . "dev"))
fixture-go-mod-with-block)
(testing-parse-mod "parse-go.mod-complete"
'(("github.com/corp/arbitrary-repo" . "v0.0.2")
("one.example.com/abitrary/repo" . "v1.1.111")
("hub.jazz.net/git/user/project/sub/directory" . "v1.1.19")
("hub.jazz.net/git/user/project" . "v1.1.18")
("launchpad.net/~user/project/branch/sub/directory" . "v1.1.17")
("launchpad.net/~user/project/branch" . "v1.1.16")
("launchpad.net/project/series/sub/directory" . "v1.1.15")
("launchpad.net/project/series" . "v1.1.14")
("launchpad.net/project" . "v1.1.13")
("bitbucket.org/user/project/sub/directory" . "v1.11.21")
("bitbucket.org/user/project" . "v1.11.20")
("k8s.io/kubernetes/subproject" . "v1.1.101")
("github.com/user/project/sub/directory" . "v1.1.12")
("github.com/user/project" . "v1.1.11")
("github.com/go-check/check" . "v0.0.0-20140225173054-eb6ee6f84d0a"))
fixture-go-mod-complete)
(test-end "import go")
|