From 8120c06edc704fe3f1cbf64f48eaaf65619eb3d1 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 15 Apr 2024 15:21:43 +0200 Subject: [PATCH] refactor: rename function --- internal/enginenetx/statspolicy.go | 5 +++-- internal/enginenetx/statspolicy_test.go | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/enginenetx/statspolicy.go b/internal/enginenetx/statspolicy.go index c300a33689..e6728c5dbc 100644 --- a/internal/enginenetx/statspolicy.go +++ b/internal/enginenetx/statspolicy.go @@ -65,7 +65,7 @@ func (p *statsPolicy) LookupTactics(ctx context.Context, domain string, port str // known-to-work cached tactics have become obsolete. // give priority to what we know from stats - for _, t := range statsPolicyPostProcessTactics(p.Stats.LookupTactics(domain, port)) { + for _, t := range statsPolicyFilterStatsTactics(p.Stats.LookupTactics(domain, port)) { maybeEmitTactic(t) } @@ -78,7 +78,8 @@ func (p *statsPolicy) LookupTactics(ctx context.Context, domain string, port str return out } -func statsPolicyPostProcessTactics(tactics []*statsTactic, good bool) (out []*httpsDialerTactic) { +// statsPolicyFilterStatsTactics filters the tactics generated by consulting the stats. +func statsPolicyFilterStatsTactics(tactics []*statsTactic, good bool) (out []*httpsDialerTactic) { // when good is false, it means p.Stats.LookupTactics failed if !good { return diff --git a/internal/enginenetx/statspolicy_test.go b/internal/enginenetx/statspolicy_test.go index e7c66514e9..31880dccf6 100644 --- a/internal/enginenetx/statspolicy_test.go +++ b/internal/enginenetx/statspolicy_test.go @@ -319,9 +319,9 @@ func (p *mocksPolicy) LookupTactics(ctx context.Context, domain string, port str return p.MockLookupTactics(ctx, domain, port) } -func TestStatsPolicyPostProcessTactics(t *testing.T) { +func TestStatsPolicyFilterStatsTactics(t *testing.T) { t.Run("we do nothing when good is false", func(t *testing.T) { - tactics := statsPolicyPostProcessTactics(nil, false) + tactics := statsPolicyFilterStatsTactics(nil, false) if len(tactics) != 0 { t.Fatal("expected zero-lenght return value") } @@ -390,7 +390,7 @@ func TestStatsPolicyPostProcessTactics(t *testing.T) { }, } - got := statsPolicyPostProcessTactics(input, true) + got := statsPolicyFilterStatsTactics(input, true) if len(got) != 1 { t.Fatal("expected just one element")