Skip to content

Commit 5079ac6

Browse files
committed
BUG/MINOR: tests: fix compare test generator
1 parent e7288dc commit 5079ac6

7 files changed

Lines changed: 59 additions & 28 deletions

File tree

cmd/struct_equal_generator/generate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ func generateEqualAndDiff(opt generateEqualAndDiffOptions) error {
5353
}
5454

5555
func generateCompareTests(opt generateEqualAndDiffOptions) error {
56-
var metadataIndex int
56+
metadataIndex := -1
5757
for i, f := range opt.Fields {
5858
if f.Name == "Metadata" {
5959
metadataIndex = i
6060
break
6161
}
6262
}
63-
if metadataIndex > 0 {
63+
if metadataIndex > -1 {
6464
opt.Fields = append(opt.Fields[:metadataIndex], opt.Fields[metadataIndex+1:]...)
6565
}
6666
if opt.Mode == "array" {

models/group_compare_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/mailers_section_base_compare_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/trace_entry_compare_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/userlist_base_compare_test.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/configuration_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ frontend test_2 from test_defaults
715715
stats show-modules
716716
stats realm HAProxy\\ Statistics
717717
718-
backend test
718+
backend test # my comment
719719
mode http
720720
balance roundrobin
721721
hash-type consistent sdbm avalanche
@@ -740,13 +740,13 @@ backend test
740740
option splice-response
741741
option http-restrict-req-hdr-names preserve
742742
default-server fall 2s rise 4s inter 5s port 8888 ws auto pool-low-conn 128 log-bufsize 6 force-sslv3
743-
stick store-request src table test
743+
stick store-request src table test # my comment
744744
stick match src table test
745745
stick on src table test
746746
stick store-response src
747747
stick store-response src_port table test_port
748748
stick store-response src table test if TRUE
749-
tcp-response content accept if TRUE
749+
tcp-response content accept if TRUE # my comment
750750
tcp-response content reject if FALSE
751751
tcp-response content lua.foo param1 param2 if FALSE
752752
tcp-response content set-bandwidth-limit my-limit limit 1m period 10s
@@ -778,14 +778,14 @@ backend test
778778
cookie BLA rewrite httponly nocache
779779
option external-check
780780
external-check command /bin/false
781-
use-server webserv if TRUE
781+
use-server webserv if TRUE # my comment
782782
use-server webserv2 unless TRUE
783783
server webserv 192.168.1.1:9200 maxconn 1000 ssl weight 10 inter 2s cookie BLAH slowstart 6000 proxy-v2-options authority,crc32c ws h1 pool-low-conn 128 id 1234 pool-purge-delay 10s tcp-ut 2s curves secp384r1 client-sigalgs ECDSA+SHA256:RSA+SHA256 sigalgs ECDSA+SHA256 log-bufsize 10 set-proxy-v2-tlv-fmt(0x20) %[fc_pp_tlv(0x20)] init-state fully-up # my comment
784784
server webserv2 192.168.1.1:9300 maxconn 1000 ssl weight 10 inter 2s cookie BLAH slowstart 6000 proxy-v2-options authority,crc32c ws h1 pool-low-conn 128 hash-key akey pool-conn-name apoolconnname # {"comment": "my structured comment", "id": "my_random_id_for_server"}
785-
http-request set-dst hdr(x-dst)
785+
http-request set-dst hdr(x-dst) # my comment
786786
http-request set-dst-port int(4000)
787787
http-request set-uri %[url,regsub(^/metrics/,/,)] if { path_beg /metrics }
788-
http-check connect
788+
http-check connect # my comment
789789
http-check send meth GET uri / ver HTTP/1.1 hdr host haproxy.1wt.eu
790790
http-check expect status 200-399
791791
http-check connect port 443 ssl sni haproxy.1wt.eu
@@ -799,7 +799,7 @@ backend test
799799
http-check set-var-fmt(check.port) int(1234)
800800
http-check send-state
801801
http-check disable-on-404
802-
server-template srv 1-3 google.com:80 check
802+
server-template srv 1-3 google.com:80 check # my comment
803803
server-template site 1-10 google.com:8080 check backup
804804
server-template website 10-100 google.com:443 check no-backup
805805
server-template test 5 test.com check backup
@@ -851,7 +851,7 @@ backend test
851851
http-send-name-header X-My-Awesome-Header
852852
persist rdp-cookie(name)
853853
source 192.168.1.222 usesrc hdr_ip(hdr,occ)
854-
http-response set-fc-mark 123
854+
http-response set-fc-mark 123 # my comment
855855
http-response set-fc-tos 1 if TRUE
856856
guid guid-example
857857
@@ -992,7 +992,7 @@ http-errors website-2
992992
errorfile 404 /etc/haproxy/errorfiles/site2/404.http
993993
errorfile 501 /etc/haproxy/errorfiles/site2/501.http
994994
995-
backend test_2 from test_defaults_2
995+
backend test_2 from test_defaults_2 # {"comment": "my comment"}
996996
mode http
997997
balance roundrobin
998998
hash-type consistent sdbm avalanche
@@ -1022,7 +1022,7 @@ backend test_2 from test_defaults_2
10221022
cookie BLA rewrite httponly nocache
10231023
stick-table type ip size 100k expire 1h peers mycluster write-to t99 store http_req_rate(10s)
10241024
http-check expect rstatus some-pattern
1025-
http-error status 200 content-type "text/plain" string "My content" hdr Some-Header value
1025+
http-error status 200 content-type "text/plain" string "My content" hdr Some-Header value # {"comment": "my comment", "id": 123}
10261026
http-error status 503 content-type application/json string "My content" hdr Additional-Header value1 hdr Some-Header value
10271027
srvtcpka-cnt 10
10281028
srvtcpka-idle 10s

test/expected/structured.json

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,9 @@
571571
"load_server_state_from_file": "local",
572572
"log_tag": "bla",
573573
"max_keep_alive_queue": 101,
574+
"metadata": {
575+
"comment": "my comment"
576+
},
574577
"mode": "http",
575578
"name": "test",
576579
"nolinger": "enabled",
@@ -637,7 +640,10 @@
637640
"use_fcgi_app": "app-name",
638641
"http_check_list": [
639642
{
640-
"type": "connect"
643+
"type": "connect",
644+
"metadata": {
645+
"comment": "my comment"
646+
}
641647
},
642648
{
643649
"headers": [
@@ -716,7 +722,10 @@
716722
"http_request_rule_list": [
717723
{
718724
"expr": "hdr(x-dst)",
719-
"type": "set-dst"
725+
"type": "set-dst",
726+
"metadata": {
727+
"comment": "my comment"
728+
}
720729
},
721730
{
722731
"expr": "int(4000)",
@@ -732,7 +741,10 @@
732741
"http_response_rule_list": [
733742
{
734743
"expr": "123",
735-
"type": "set-fc-mark"
744+
"type": "set-fc-mark",
745+
"metadata": {
746+
"comment": "my comment"
747+
}
736748
},
737749
{
738750
"expr": "1",
@@ -745,7 +757,10 @@
745757
{
746758
"cond": "if",
747759
"cond_test": "TRUE",
748-
"target_server": "webserv"
760+
"target_server": "webserv",
761+
"metadata": {
762+
"comment": "my comment"
763+
}
749764
},
750765
{
751766
"cond": "unless",
@@ -757,7 +772,10 @@
757772
{
758773
"pattern": "src",
759774
"table": "test",
760-
"type": "store-request"
775+
"type": "store-request",
776+
"metadata": {
777+
"comment": "my comment"
778+
}
761779
},
762780
{
763781
"pattern": "src",
@@ -791,7 +809,10 @@
791809
"action": "accept",
792810
"cond": "if",
793811
"cond_test": "TRUE",
794-
"type": "content"
812+
"type": "content",
813+
"metadata": {
814+
"comment": "my comment"
815+
}
795816
},
796817
{
797818
"action": "reject",
@@ -961,7 +982,10 @@
961982
"fqdn": "google.com",
962983
"num_or_range": "1-3",
963984
"port": 80,
964-
"prefix": "srv"
985+
"prefix": "srv",
986+
"metadata": {
987+
"comment": "my comment"
988+
}
965989
},
966990
"test": {
967991
"backup": "enabled",
@@ -1039,6 +1063,9 @@
10391063
}
10401064
},
10411065
"test_2": {
1066+
"metadata": {
1067+
"comment": "my comment"
1068+
},
10421069
"adv_check": "httpchk",
10431070
"balance": {
10441071
"algorithm": "roundrobin"
@@ -1167,7 +1194,11 @@
11671194
"return_content_format": "string",
11681195
"return_content_type": "\"text/plain\"",
11691196
"status": 200,
1170-
"type": "status"
1197+
"type": "status",
1198+
"metadata": {
1199+
"comment": "my comment",
1200+
"id": 123
1201+
}
11711202
},
11721203
{
11731204
"return_hdrs": [

0 commit comments

Comments
 (0)