@@ -434,9 +434,20 @@ mod test {
434
434
use crate :: analyze;
435
435
use k8s_openapi:: apiextensions_apiserver:: pkg:: apis:: apiextensions:: v1:: JSONSchemaProps ;
436
436
use serde_yaml;
437
+ use std:: sync:: Once ;
438
+
439
+ static START : Once = Once :: new ( ) ;
440
+ fn init ( ) {
441
+ START . call_once ( || {
442
+ env_logger:: init ( ) ;
443
+ } ) ;
444
+ }
445
+ // To debug individual tests:
446
+ // RUST_LOG=debug cargo test --lib -- --nocapture testname
437
447
438
448
#[ test]
439
449
fn map_of_struct ( ) {
450
+ init ( ) ;
440
451
// validationsInfo from agent test
441
452
let schema_str = r#"
442
453
description: AgentStatus defines the observed state of Agent
@@ -464,7 +475,6 @@ mod test {
464
475
type: object
465
476
"# ;
466
477
let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
467
- //env_logger::init();
468
478
//println!("schema: {}", serde_json::to_string_pretty(&schema).unwrap());
469
479
470
480
let mut structs = vec ! [ ] ;
@@ -491,6 +501,7 @@ mod test {
491
501
492
502
#[ test]
493
503
fn empty_preserve_unknown_fields ( ) {
504
+ init ( ) ;
494
505
let schema_str = r#"
495
506
description: |-
496
507
Identifies servers in the same namespace for which this authorization applies.
@@ -531,6 +542,7 @@ type: object
531
542
532
543
#[ test]
533
544
fn int_or_string ( ) {
545
+ init ( ) ;
534
546
let schema_str = r#"
535
547
properties:
536
548
port:
@@ -556,6 +568,7 @@ type: object
556
568
557
569
#[ test]
558
570
fn enum_string ( ) {
571
+ init ( ) ;
559
572
let schema_str = r#"
560
573
properties:
561
574
operator:
@@ -571,7 +584,6 @@ type: object
571
584
"# ;
572
585
573
586
let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
574
- //env_logger::init();
575
587
let mut structs = vec ! [ ] ;
576
588
analyze ( schema, "" , "MatchExpressions" , 0 , & mut structs) . unwrap ( ) ;
577
589
println ! ( "got {:?}" , structs) ;
@@ -599,6 +611,7 @@ type: object
599
611
600
612
#[ test]
601
613
fn enum_string_within_container ( ) {
614
+ init ( ) ;
602
615
let schema_str = r#"
603
616
description: Endpoint
604
617
properties:
@@ -607,8 +620,6 @@ type: object
607
620
properties:
608
621
action:
609
622
default: replace
610
- description: Action to perform based on regex matching.
611
- Default is 'replace'
612
623
enum:
613
624
- replace
614
625
- keep
@@ -627,7 +638,6 @@ type: object
627
638
"# ;
628
639
629
640
let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
630
- //env_logger::init();
631
641
let mut structs = vec ! [ ] ;
632
642
analyze ( schema, "" , "Endpoint" , 0 , & mut structs) . unwrap ( ) ;
633
643
println ! ( "got {:?}" , structs) ;
@@ -664,6 +674,7 @@ type: object
664
674
#[ test]
665
675
#[ ignore] // oneof support not done
666
676
fn enum_oneof ( ) {
677
+ init ( ) ;
667
678
let schema_str = r#"
668
679
description: "Auto-generated derived type for ServerSpec via `CustomResource`"
669
680
properties:
@@ -712,7 +723,6 @@ type: object
712
723
type: object"# ;
713
724
714
725
let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
715
- //env_logger::init();
716
726
let mut structs = vec ! [ ] ;
717
727
analyze ( schema, "" , "ServerSpec" , 0 , & mut structs) . unwrap ( ) ;
718
728
println ! ( "got {:?}" , structs) ;
@@ -764,6 +774,7 @@ type: object
764
774
765
775
#[ test]
766
776
fn service_monitor_params ( ) {
777
+ init ( ) ;
767
778
let schema_str = r#"
768
779
properties:
769
780
endpoints:
@@ -785,7 +796,6 @@ type: object
785
796
type: object
786
797
"# ;
787
798
let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
788
- //env_logger::init();
789
799
let mut structs = vec ! [ ] ;
790
800
analyze ( schema, "Endpoints" , "ServiceMonitor" , 0 , & mut structs) . unwrap ( ) ;
791
801
println ! ( "got {:?}" , structs) ;
@@ -811,6 +821,7 @@ type: object
811
821
812
822
#[ test]
813
823
fn integer_handling_in_maps ( ) {
824
+ init ( ) ;
814
825
// via https://istio.io/latest/docs/reference/config/networking/destination-rule/
815
826
// distribute:
816
827
// - from: us-west/zone1/*
0 commit comments