@@ -10,9 +10,6 @@ use serde_json::{json, Map, Value};
10
10
mod common;
11
11
use common:: * ;
12
12
13
- const SCHEMA_BASE : & str = "https://pgxn.org/meta/v1" ;
14
- const SCHEMA_ID : & str = "https://pgxn.org/meta/v1/distribution.schema.json" ;
15
-
16
13
#[ test]
17
14
fn test_schema_v1 ( ) -> Result < ( ) , Box < dyn Error > > {
18
15
test_schema_version ( 1 )
@@ -30,7 +27,8 @@ fn test_corpus_v1_valid() -> Result<(), Box<dyn Error>> {
30
27
// Load the schemas and compile the root schema.
31
28
let mut compiler = new_compiler ( "schema/v1" ) ?;
32
29
let mut schemas = Schemas :: new ( ) ;
33
- let index = compiler. compile ( SCHEMA_ID , & mut schemas) ?;
30
+ let id = id_for ( 1 , "distribution" ) ;
31
+ let index = compiler. compile ( & id, & mut schemas) ?;
34
32
35
33
// Test each meta JSON in the corpus.
36
34
let file = File :: open ( "tests/corpus/v1/valid.txt" ) ?;
@@ -52,7 +50,8 @@ fn test_corpus_v1_invalid() -> Result<(), Box<dyn Error>> {
52
50
// Load the schemas and compile the root schema.
53
51
let mut compiler = new_compiler ( "schema/v1" ) ?;
54
52
let mut schemas = Schemas :: new ( ) ;
55
- let index = compiler. compile ( SCHEMA_ID , & mut schemas) ?;
53
+ let id = id_for ( 1 , "distribution" ) ;
54
+ let index = compiler. compile ( & id, & mut schemas) ?;
56
55
57
56
// Test each meta JSON in the corpus.
58
57
let file = File :: open ( "tests/corpus/v1/invalid.txt" ) ?;
@@ -76,24 +75,22 @@ fn test_corpus_v1_invalid() -> Result<(), Box<dyn Error>> {
76
75
fn test_v1_term ( ) -> Result < ( ) , Box < dyn Error > > {
77
76
// Load the schemas and compile the term schema.
78
77
let compiler = new_compiler ( "schema/v1" ) ?;
79
- let id = format ! ( "{SCHEMA_BASE}/term.schema.json" ) ;
80
- test_term_schema ( compiler, & id)
78
+ test_term_schema ( compiler, 1 )
81
79
}
82
80
83
81
#[ test]
84
82
fn test_v1_tags ( ) -> Result < ( ) , Box < dyn Error > > {
85
83
// Load the schemas and compile the tags schema.
86
84
let compiler = new_compiler ( "schema/v1" ) ?;
87
- let id = format ! ( "{SCHEMA_BASE}/tags.schema.json" ) ;
88
- test_tags_schema ( compiler, & id)
85
+ test_tags_schema ( compiler, 1 )
89
86
}
90
87
91
88
#[ test]
92
89
fn test_v1_version ( ) -> Result < ( ) , Box < dyn Error > > {
93
90
// Load the schemas and compile the version schema.
94
91
let mut compiler = new_compiler ( "schema/v1" ) ?;
95
92
let mut schemas = Schemas :: new ( ) ;
96
- let id = format ! ( "{SCHEMA_BASE}/ version.schema.json ") ;
93
+ let id = id_for ( 1 , " version") ;
97
94
let idx = compiler. compile ( & id, & mut schemas) ?;
98
95
99
96
for valid_version in VALID_SEMVERS {
@@ -118,7 +115,7 @@ fn test_v1_version_range() -> Result<(), Box<dyn Error>> {
118
115
// Load the schemas and compile the version_range schema.
119
116
let mut compiler = new_compiler ( "schema/v1" ) ?;
120
117
let mut schemas = Schemas :: new ( ) ;
121
- let id = format ! ( "{SCHEMA_BASE}/ version_range.schema.json ") ;
118
+ let id = id_for ( 1 , " version_range") ;
122
119
let idx = compiler. compile ( & id, & mut schemas) ?;
123
120
124
121
for valid_version in VALID_SEMVERS {
@@ -189,7 +186,7 @@ fn test_v1_license() -> Result<(), Box<dyn Error>> {
189
186
// Load the schemas and compile the license schema.
190
187
let mut compiler = new_compiler ( "schema/v1" ) ?;
191
188
let mut schemas = Schemas :: new ( ) ;
192
- let id = format ! ( "{SCHEMA_BASE}/ license.schema.json ") ;
189
+ let id = id_for ( 1 , " license") ;
193
190
let idx = compiler. compile ( & id, & mut schemas) ?;
194
191
195
192
// Test valid license values.
@@ -257,7 +254,7 @@ fn test_v1_provides() -> Result<(), Box<dyn Error>> {
257
254
// Load the schemas and compile the provides schema.
258
255
let mut compiler = new_compiler ( "schema/v1" ) ?;
259
256
let mut schemas = Schemas :: new ( ) ;
260
- let id = format ! ( "{SCHEMA_BASE}/ provides.schema.json ") ;
257
+ let id = id_for ( 1 , " provides") ;
261
258
let idx = compiler. compile ( & id, & mut schemas) ?;
262
259
263
260
for valid_provides in [
@@ -356,7 +353,7 @@ fn test_v1_extension() -> Result<(), Box<dyn Error>> {
356
353
// Load the schemas and compile the extension schema.
357
354
let mut compiler = new_compiler ( "schema/v1" ) ?;
358
355
let mut schemas = Schemas :: new ( ) ;
359
- let id = format ! ( "{SCHEMA_BASE}/ extension.schema.json ") ;
356
+ let id = id_for ( 1 , " extension") ;
360
357
let idx = compiler. compile ( & id, & mut schemas) ?;
361
358
362
359
for valid_extension in [
@@ -532,7 +529,7 @@ fn test_v1_maintainer() -> Result<(), Box<dyn Error>> {
532
529
// Load the schemas and compile the maintainer schema.
533
530
let mut compiler = new_compiler ( "schema/v1" ) ?;
534
531
let mut schemas = Schemas :: new ( ) ;
535
- let id = format ! ( "{SCHEMA_BASE}/ maintainer.schema.json ") ;
532
+ let id = id_for ( 1 , " maintainer") ;
536
533
let idx = compiler. compile ( & id, & mut schemas) ?;
537
534
538
535
for valid_maintainer in [
@@ -581,7 +578,7 @@ fn test_v1_meta_spec() -> Result<(), Box<dyn Error>> {
581
578
// Load the schemas and compile the maintainer schema.
582
579
let mut compiler = new_compiler ( "schema/v1" ) ?;
583
580
let mut schemas = Schemas :: new ( ) ;
584
- let id = format ! ( "{SCHEMA_BASE}/ meta-spec.schema.json ") ;
581
+ let id = id_for ( 1 , " meta-spec") ;
585
582
let idx = compiler. compile ( & id, & mut schemas) ?;
586
583
587
584
for valid_meta_spec in [
@@ -635,7 +632,7 @@ fn test_v1_bugtracker() -> Result<(), Box<dyn Error>> {
635
632
// Load the schemas and compile the maintainer schema.
636
633
let mut compiler = new_compiler ( "schema/v1" ) ?;
637
634
let mut schemas = Schemas :: new ( ) ;
638
- let id = format ! ( "{SCHEMA_BASE}/ bugtracker.schema.json ") ;
635
+ let id = id_for ( 1 , " bugtracker") ;
639
636
let idx = compiler. compile ( & id, & mut schemas) ?;
640
637
641
638
for valid_bugtracker in [
@@ -689,7 +686,7 @@ fn test_v1_no_index() -> Result<(), Box<dyn Error>> {
689
686
// Load the schemas and compile the maintainer schema.
690
687
let mut compiler = new_compiler ( "schema/v1" ) ?;
691
688
let mut schemas = Schemas :: new ( ) ;
692
- let id = format ! ( "{SCHEMA_BASE}/ no_index.schema.json ") ;
689
+ let id = id_for ( 1 , " no_index") ;
693
690
let idx = compiler. compile ( & id, & mut schemas) ?;
694
691
695
692
for valid_no_index in [
@@ -754,7 +751,7 @@ fn test_v1_prereq_relationship() -> Result<(), Box<dyn Error>> {
754
751
// Load the schemas and compile the maintainer schema.
755
752
let mut compiler = new_compiler ( "schema/v1" ) ?;
756
753
let mut schemas = Schemas :: new ( ) ;
757
- let id = format ! ( "{SCHEMA_BASE}/ prereq_relationship.schema.json ") ;
754
+ let id = id_for ( 1 , " prereq_relationship") ;
758
755
let idx = compiler. compile ( & id, & mut schemas) ?;
759
756
760
757
for valid_prereq_relationship in [
@@ -807,7 +804,7 @@ fn test_v1_prereq_phase() -> Result<(), Box<dyn Error>> {
807
804
// Load the schemas and compile the maintainer schema.
808
805
let mut compiler = new_compiler ( "schema/v1" ) ?;
809
806
let mut schemas = Schemas :: new ( ) ;
810
- let id = format ! ( "{SCHEMA_BASE}/ prereq_phase.schema.json ") ;
807
+ let id = id_for ( 1 , " prereq_phase") ;
811
808
let idx = compiler. compile ( & id, & mut schemas) ?;
812
809
813
810
for valid_prereq_phase in [
@@ -919,7 +916,7 @@ fn test_v1_prereqs() -> Result<(), Box<dyn Error>> {
919
916
// Load the schemas and compile the maintainer schema.
920
917
let mut compiler = new_compiler ( "schema/v1" ) ?;
921
918
let mut schemas = Schemas :: new ( ) ;
922
- let id = format ! ( "{SCHEMA_BASE}/ prereqs.schema.json ") ;
919
+ let id = id_for ( 1 , " prereqs") ;
923
920
let idx = compiler. compile ( & id, & mut schemas) ?;
924
921
925
922
for valid_prereqs in [
@@ -1067,7 +1064,7 @@ fn test_v1_repository() -> Result<(), Box<dyn Error>> {
1067
1064
// Load the schemas and compile the repository schema.
1068
1065
let mut compiler = new_compiler ( "schema/v1" ) ?;
1069
1066
let mut schemas = Schemas :: new ( ) ;
1070
- let id = format ! ( "{SCHEMA_BASE}/ repository.schema.json ") ;
1067
+ let id = id_for ( 1 , " repository") ;
1071
1068
let idx = compiler. compile ( & id, & mut schemas) ?;
1072
1069
1073
1070
for valid_repository in [
@@ -1144,7 +1141,7 @@ fn test_v1_resources() -> Result<(), Box<dyn Error>> {
1144
1141
// Load the schemas and compile the resources schema.
1145
1142
let mut compiler = new_compiler ( "schema/v1" ) ?;
1146
1143
let mut schemas = Schemas :: new ( ) ;
1147
- let id = format ! ( "{SCHEMA_BASE}/ resources.schema.json ") ;
1144
+ let id = id_for ( 1 , " resources") ;
1148
1145
let idx = compiler. compile ( & id, & mut schemas) ?;
1149
1146
1150
1147
for valid_resources in [
@@ -1281,7 +1278,8 @@ fn test_v1_distribution() -> Result<(), Box<dyn Error>> {
1281
1278
// Load the schemas and compile the distribution schema.
1282
1279
let mut compiler = new_compiler ( "schema/v1" ) ?;
1283
1280
let mut schemas = Schemas :: new ( ) ;
1284
- let idx = compiler. compile ( SCHEMA_ID , & mut schemas) ?;
1281
+ let id = id_for ( 1 , "distribution" ) ;
1282
+ let idx = compiler. compile ( & id, & mut schemas) ?;
1285
1283
1286
1284
// Make sure the valid distribution is in fact valid.
1287
1285
let meta = valid_distribution ( ) ;
0 commit comments