@@ -612,7 +612,7 @@ func TestNewConfigFromBytes(t *testing.T) {
612
612
Host api.coralogix.com
613
613
Port 443
614
614
URI /logs/rest/singles
615
- Header private_key Private_Key-Super-Complex-testing-123
615
+ Header private_key 0886464e-ccba-ff8b-83ff-4fa9c3cc0f72
616
616
Format json_lines
617
617
Compress On
618
618
` ),
@@ -662,6 +662,70 @@ func TestNewConfigFromBytes(t *testing.T) {
662
662
},
663
663
expectedError : false ,
664
664
},
665
+ {
666
+ name : "test valid large configuration bug 157 - 2nd case" ,
667
+ config : []byte (`[INPUT]
668
+ Name forward
669
+ Host 0.0.0.0
670
+ Port 24284
671
+
672
+ [OUTPUT]
673
+ Name http
674
+ Match dummy.*
675
+ Host api.coralogix.com
676
+ Port 443
677
+ URI /logs/rest/singles
678
+ Header private_key EXPLICITLY-LONG-KEY-12345
679
+ Format json_lines
680
+ Compress On
681
+ ` ),
682
+ expected : Config {
683
+ Sections : []ConfigSection {{
684
+ Type : InputSection ,
685
+ Fields : []Field {
686
+ {Key : "Name" , Values : []Value {{
687
+ String : stringPtr ("forward" ),
688
+ }}},
689
+ {Key : "Host" , Values : []Value {{
690
+ String : stringPtr ("0.0.0.0" ),
691
+ }}},
692
+ {Key : "Port" , Values : []Value {{
693
+ String : stringPtr ("24284" ),
694
+ }}},
695
+ },
696
+ }, {
697
+ Type : OutputSection ,
698
+ Fields : []Field {
699
+ {Key : "Name" , Values : []Value {{
700
+ String : stringPtr ("http" ),
701
+ }}},
702
+ {Key : "Match" , Values : []Value {{
703
+ String : stringPtr ("dummy.*" ),
704
+ }}},
705
+ {Key : "Host" , Values : []Value {{
706
+ String : stringPtr ("api.coralogix.com" ),
707
+ }}},
708
+ {Key : "Port" , Values : []Value {{
709
+ String : stringPtr ("443" ),
710
+ }}},
711
+ {Key : "URI" , Values : []Value {{
712
+ String : stringPtr ("/logs/rest/singles" ),
713
+ }}},
714
+ {Key : "Header" , Values : []Value {{
715
+ String : stringPtr ("private_key EXPLICITLY-LONG-KEY-12345" ),
716
+ }}},
717
+ {Key : "Format" , Values : []Value {{
718
+ String : stringPtr ("json_lines" ),
719
+ }}},
720
+ {Key : "Compress" , Values : []Value {{
721
+ String : stringPtr ("On" ),
722
+ }}},
723
+ },
724
+ }},
725
+ },
726
+ expectedError : false ,
727
+ },
728
+
665
729
{
666
730
name : "test valid larger configuration" ,
667
731
config : []byte (`[INPUT]
@@ -831,9 +895,6 @@ func TestNewConfigFromBytes(t *testing.T) {
831
895
},
832
896
}
833
897
834
- //stripIndentation := regexp.MustCompile("\n[\t]+")
835
- //stripMultipleSpaces := regexp.MustCompile(`[\ ]{2,}`)
836
-
837
898
for _ , tc := range tt {
838
899
t .Run (tc .name , func (t * testing.T ) {
839
900
cfg , err := ParseINI (tc .config )
@@ -859,40 +920,7 @@ func TestNewConfigFromBytes(t *testing.T) {
859
920
t .Errorf ("section[%d] wants %v != got %v" , idx , want , got )
860
921
return
861
922
}
862
-
863
- /*
864
- for fidx, field := range section.Fields {
865
- if want, got := len(field.Values), len(cfg.Sections[idx].Fields[fidx].Values); want != got {
866
- t.Errorf("section[%d].fields[%s:%d] %d != got %d", idx, field.Key, fidx, want, got)
867
- return
868
- }
869
- for vidx, value := range cfg.Sections[idx].Fields[fidx].Values {
870
- if !value.Equals(field.Values[vidx]) {
871
- t.Errorf("unexpected value section[%d].fields[%s]", idx, field.Key)
872
- return
873
- }
874
- }
875
- }
876
- */
877
923
}
878
-
879
- /*
880
- config := stripIndentation.ReplaceAll(tc.config, []byte("\n"))
881
- config = stripMultipleSpaces.ReplaceAll(config, []byte(" "))
882
-
883
- if ini, err := cfg.DumpINI(); err != nil {
884
- t.Error(err)
885
- return
886
- } else {
887
- ini = stripIndentation.ReplaceAll(ini, []byte("\n"))
888
- ini = stripMultipleSpaces.ReplaceAll(ini, []byte(""))
889
- if !bytes.Equal(ini, config) {
890
- fmt.Printf("\n'%s'\n != \n'%s'\n", string(config), string(ini))
891
- t.Errorf("unable to reconstitute INI")
892
- }
893
- return
894
- }
895
- */
896
924
})
897
925
}
898
926
}
0 commit comments