From 3ffec44b20241176c98493453b6f8b710adeada3 Mon Sep 17 00:00:00 2001 From: Vincent Roy Date: Thu, 23 Jul 2026 18:45:24 +0200 Subject: [PATCH] sds-go: add ScanWithValidation regression test Add a minimal Go test that calls ScanWithValidation. A follow-up should configure a third_party_active_checker and assert MatchStatus, mirroring the Rust coverage in match_validation.rs. --- sds-go/go/scanner_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sds-go/go/scanner_test.go b/sds-go/go/scanner_test.go index f0956a32..445c3018 100644 --- a/sds-go/go/scanner_test.go +++ b/sds-go/go/scanner_test.go @@ -1083,3 +1083,25 @@ func TestCreateScannerFailsOnSupportingRuleWithMatchAction(t *testing.T) { t.Fatalf("expected ErrSupportingRuleHasMatchAction, got: %v", err) } } + +// TODO: truly exercise match validation by configuring a rule with a +// third_party_active_checker (e.g. CustomHttp) and asserting MatchStatus +// after ScanWithValidation(..., true), similar to the Rust tests in +// sds/src/scanner/test/match_validation.rs. +func TestScanWithValidation(t *testing.T) { + scanner, err := CreateScanner([]RuleConfig{ + NewMatchingRule("digits", `\d{16}`, ExtraConfig{}), + }) + if err != nil { + t.Fatal(err) + } + defer scanner.Delete() + + result, err := scanner.ScanWithValidation([]byte("1234567890123456"), true) + if err != nil { + t.Fatal(err) + } + if len(result.Matches) != 1 { + t.Fatalf("expected 1 match, got %d", len(result.Matches)) + } +}