@@ -30,6 +30,21 @@ import org.ossreviewtoolkit.model.SourceCodeOrigin
30
30
import org.ossreviewtoolkit.model.VcsInfo
31
31
import org.ossreviewtoolkit.model.VcsType
32
32
33
+ private val ARTIFACT_PROVENANCE = ArtifactProvenance (
34
+ sourceArtifact = RemoteArtifact .EMPTY .copy(
35
+ url = " https://host/path/file.zip"
36
+ )
37
+ )
38
+
39
+ private val REPOSITORY_PROVENANCE = RepositoryProvenance (
40
+ vcsInfo = VcsInfo (
41
+ type = VcsType .GIT ,
42
+ url = " ssh://git@host/repo.git" ,
43
+ revision = " "
44
+ ),
45
+ resolvedRevision = " 12345678"
46
+ )
47
+
33
48
private fun vcsPackageConfig (name : String , revision : String , url : String ) =
34
49
PackageConfiguration (
35
50
id = Identifier .EMPTY .copy(name = name),
@@ -53,14 +68,7 @@ class PackageConfigurationTest : WordSpec({
53
68
54
69
config.matches(
55
70
config.id,
56
- RepositoryProvenance (
57
- vcsInfo = VcsInfo (
58
- type = VcsType .GIT ,
59
- url = "ssh://git@host/repo.git",
60
- revision = ""
61
- ),
62
- resolvedRevision = "12345678"
63
- )
71
+ REPOSITORY_PROVENANCE
64
72
) shouldBe true
65
73
}
66
74
@@ -69,14 +77,7 @@ class PackageConfigurationTest : WordSpec({
69
77
70
78
config.matches(
71
79
Identifier .EMPTY .copy(name = "some-other-name"),
72
- RepositoryProvenance (
73
- vcsInfo = VcsInfo (
74
- type = VcsType .GIT ,
75
- url = "ssh://git@host/repo.git",
76
- revision = ""
77
- ),
78
- resolvedRevision = "12345678"
79
- )
80
+ REPOSITORY_PROVENANCE
80
81
) shouldBe false
81
82
}
82
83
@@ -85,30 +86,16 @@ class PackageConfigurationTest : WordSpec({
85
86
86
87
config.matches(
87
88
config.id,
88
- RepositoryProvenance (
89
- vcsInfo = VcsInfo (
90
- type = VcsType .GIT ,
91
- url = "ssh://host/repo.git",
92
- revision = ""
93
- ),
94
- resolvedRevision = "12345678"
95
- )
96
- ) shouldBe true
89
+ REPOSITORY_PROVENANCE .copy(vcsInfo = REPOSITORY_PROVENANCE .vcsInfo.copy(url = "ssh://host/repo.git"))
90
+ )
97
91
}
98
92
99
93
" return false if only resolved revision is not equal to the matcher's revision" {
100
94
val config = vcsPackageConfig(name = "some-name", revision = "12345678", url = "ssh://git@host/repo.git")
101
95
102
96
config.matches(
103
97
config.id,
104
- RepositoryProvenance (
105
- vcsInfo = VcsInfo (
106
- type = VcsType .GIT ,
107
- url = "ssh://git@host/repo.git",
108
- revision = "12345678"
109
- ),
110
- resolvedRevision = "12"
111
- )
98
+ REPOSITORY_PROVENANCE .copy(resolvedRevision = "12")
112
99
) shouldBe false
113
100
}
114
101
@@ -117,11 +104,7 @@ class PackageConfigurationTest : WordSpec({
117
104
118
105
config.matches(
119
106
config.id,
120
- ArtifactProvenance (
121
- sourceArtifact = RemoteArtifact .EMPTY .copy(
122
- url = "https://host/path/file.zip"
123
- )
124
- )
107
+ ARTIFACT_PROVENANCE
125
108
) shouldBe true
126
109
}
127
110
@@ -130,8 +113,8 @@ class PackageConfigurationTest : WordSpec({
130
113
131
114
config.matches(
132
115
config.id,
133
- ArtifactProvenance (
134
- sourceArtifact = RemoteArtifact . EMPTY .copy(
116
+ ARTIFACT_PROVENANCE .copy (
117
+ sourceArtifact = ARTIFACT_PROVENANCE .sourceArtifact .copy(
135
118
url = "https://host/path/some-other-file.zip"
136
119
)
137
120
)
@@ -146,14 +129,7 @@ class PackageConfigurationTest : WordSpec({
146
129
147
130
config.matches(
148
131
config.id.copy(type = "gradle"),
149
- RepositoryProvenance (
150
- vcsInfo = VcsInfo (
151
- type = VcsType .GIT ,
152
- url = "ssh://git@host/repo.git",
153
- revision = ""
154
- ),
155
- resolvedRevision = "12345678"
156
- )
132
+ REPOSITORY_PROVENANCE
157
133
) shouldBe true
158
134
}
159
135
@@ -166,14 +142,7 @@ class PackageConfigurationTest : WordSpec({
166
142
167
143
config.matches(
168
144
config.id,
169
- RepositoryProvenance (
170
- vcsInfo = VcsInfo (
171
- type = VcsType .GIT ,
172
- url = "ssh://git@host/repo.git",
173
- revision = ""
174
- ),
175
- resolvedRevision = "12345678"
176
- )
145
+ REPOSITORY_PROVENANCE
177
146
) shouldBe true
178
147
}
179
148
@@ -186,11 +155,7 @@ class PackageConfigurationTest : WordSpec({
186
155
187
156
config.matches(
188
157
config.id,
189
- ArtifactProvenance (
190
- sourceArtifact = RemoteArtifact .EMPTY .copy(
191
- url = "https://host/path/some-other-file.zip"
192
- )
193
- )
158
+ ARTIFACT_PROVENANCE
194
159
) shouldBe true
195
160
}
196
161
@@ -203,14 +168,7 @@ class PackageConfigurationTest : WordSpec({
203
168
204
169
config.matches(
205
170
config.id,
206
- RepositoryProvenance (
207
- vcsInfo = VcsInfo (
208
- type = VcsType .GIT ,
209
- url = "ssh://git@host/repo.git",
210
- revision = ""
211
- ),
212
- resolvedRevision = "12345678"
213
- )
171
+ REPOSITORY_PROVENANCE
214
172
) shouldBe false
215
173
}
216
174
@@ -219,10 +177,7 @@ class PackageConfigurationTest : WordSpec({
219
177
220
178
config.matches(
221
179
config.id,
222
- RepositoryProvenance (
223
- vcsInfo = VcsInfo .EMPTY ,
224
- resolvedRevision = "12345678"
225
- )
180
+ REPOSITORY_PROVENANCE
226
181
) shouldBe true
227
182
}
228
183
}
0 commit comments