From e539199eb4a5a1b60587c934d828e77fda3d0641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Sat, 14 Oct 2023 12:32:19 +0200 Subject: [PATCH] add buildfilter test --- pkg/filters/filters_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/filters/filters_test.go b/pkg/filters/filters_test.go index ec4e3e785..2b5cb5e70 100644 --- a/pkg/filters/filters_test.go +++ b/pkg/filters/filters_test.go @@ -138,6 +138,26 @@ func TestFilterByNoneScope(t *testing.T) { container.AssertExpectations(t) } +func TestBuildFilterNoneScope(t *testing.T) { + filter, desc := BuildFilter(nil, nil, false, "none") + + assert.Contains(t, desc, "without a scope") + + scoped := new(mocks.FilterableContainer) + scoped.On("Enabled").Return(false, false) + scoped.On("Scope").Return("anyscope", true) + + unscoped := new(mocks.FilterableContainer) + unscoped.On("Enabled").Return(false, false) + unscoped.On("Scope").Return("", false) + + assert.False(t, filter(scoped)) + assert.True(t, filter(unscoped)) + + scoped.AssertExpectations(t) + unscoped.AssertExpectations(t) +} + func TestFilterByDisabledLabel(t *testing.T) { filter := FilterByDisabledLabel(NoFilter) assert.NotNil(t, filter)