From 92efe658fc2b6872ded6373ba0664c5d53028cd7 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Wed, 6 Dec 2023 12:11:09 -0800 Subject: [PATCH] Simplify limiter test --- sdk/metric/internal/aggregate/limit_test.go | 58 +++++++++------------ 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/sdk/metric/internal/aggregate/limit_test.go b/sdk/metric/internal/aggregate/limit_test.go index ba1982b4aa6..590f91da88e 100644 --- a/sdk/metric/internal/aggregate/limit_test.go +++ b/sdk/metric/internal/aggregate/limit_test.go @@ -21,37 +21,31 @@ import ( "go.opentelemetry.io/otel/attribute" ) -func TestLimiter(t *testing.T) { - t.Run("Attributes", testAttributes()) -} - -func testAttributes() func(*testing.T) { +func TestLimiterAttributes(t *testing.T) { m := map[attribute.Set]struct{}{alice: {}} - return func(t *testing.T) { - t.Run("NoLimit", func(t *testing.T) { - l := newLimiter[struct{}](0) - assert.Equal(t, alice, l.Attributes(alice, m)) - assert.Equal(t, bob, l.Attributes(bob, m)) - }) - - t.Run("NotAtLimit/Exists", func(t *testing.T) { - l := newLimiter[struct{}](3) - assert.Equal(t, alice, l.Attributes(alice, m)) - }) - - t.Run("NotAtLimit/DoesNotExist", func(t *testing.T) { - l := newLimiter[struct{}](3) - assert.Equal(t, bob, l.Attributes(bob, m)) - }) - - t.Run("AtLimit/Exists", func(t *testing.T) { - l := newLimiter[struct{}](2) - assert.Equal(t, alice, l.Attributes(alice, m)) - }) - - t.Run("AtLimit/DoesNotExist", func(t *testing.T) { - l := newLimiter[struct{}](2) - assert.Equal(t, overflowSet, l.Attributes(bob, m)) - }) - } + t.Run("NoLimit", func(t *testing.T) { + l := newLimiter[struct{}](0) + assert.Equal(t, alice, l.Attributes(alice, m)) + assert.Equal(t, bob, l.Attributes(bob, m)) + }) + + t.Run("NotAtLimit/Exists", func(t *testing.T) { + l := newLimiter[struct{}](3) + assert.Equal(t, alice, l.Attributes(alice, m)) + }) + + t.Run("NotAtLimit/DoesNotExist", func(t *testing.T) { + l := newLimiter[struct{}](3) + assert.Equal(t, bob, l.Attributes(bob, m)) + }) + + t.Run("AtLimit/Exists", func(t *testing.T) { + l := newLimiter[struct{}](2) + assert.Equal(t, alice, l.Attributes(alice, m)) + }) + + t.Run("AtLimit/DoesNotExist", func(t *testing.T) { + l := newLimiter[struct{}](2) + assert.Equal(t, overflowSet, l.Attributes(bob, m)) + }) }