MCPcopy Create free account
hub / github.com/bufbuild/buf / TestNesting

Function TestNesting

private/bufpkg/bufimage/bufimageutil/bufimageutil_test.go:139–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func TestNesting(t *testing.T) {
140 t.Parallel()
141 t.Run("message", func(t *testing.T) {
142 t.Parallel()
143 runDiffTest(t, "testdata/nesting", "message.txtar", WithIncludeTypes("pkg.Foo"))
144 })
145 t.Run("recursive_message", func(t *testing.T) {
146 t.Parallel()
147 // "pkg.Foo.**" additionally pulls in the otherwise-unreferenced nested
148 // types pkg.Foo.NestedButNotUsed and pkg.Foo.NestedFoo.NestedNestedFoo.
149 runDiffTest(t, "testdata/nesting", "message.recursive.txtar", WithIncludeTypes("pkg.Foo.**"))
150 })
151 t.Run("recursive_message_with_exclude", func(t *testing.T) {
152 t.Parallel()
153 // An explicitly excluded nested type is skipped by the recursive glob.
154 runDiffTest(t, "testdata/nesting", "message.recursive-exclude.txtar", WithIncludeTypes("pkg.Foo.**"), WithExcludeTypes("pkg.Foo.NestedButNotUsed"))
155 })
156 t.Run("recursenested", func(t *testing.T) {
157 t.Parallel()
158 runDiffTest(t, "testdata/nesting", "recursenested.txtar", WithIncludeTypes("pkg.Foo.NestedFoo.NestedNestedFoo"))
159 })
160 t.Run("enum", func(t *testing.T) {
161 t.Parallel()
162 runDiffTest(t, "testdata/nesting", "enum.txtar", WithIncludeTypes("pkg.FooEnum"))
163 })
164 t.Run("usingother", func(t *testing.T) {
165 t.Parallel()
166 runDiffTest(t, "testdata/nesting", "usingother.txtar", WithIncludeTypes("pkg.Baz"))
167 })
168
169 t.Run("exclude_message", func(t *testing.T) {
170 t.Parallel()
171 runDiffTest(t, "testdata/nesting", "message.exclude.txtar", WithExcludeTypes("pkg.Foo"))
172 })
173 t.Run("exclude_recursenested", func(t *testing.T) {
174 t.Parallel()
175 runDiffTest(t, "testdata/nesting", "recursenested.exclude.txtar", WithExcludeTypes("pkg.Foo.NestedFoo.NestedNestedFoo"))
176 })
177 t.Run("exclude_enum", func(t *testing.T) {
178 t.Parallel()
179 runDiffTest(t, "testdata/nesting", "enum.exclude.txtar", WithExcludeTypes("pkg.FooEnum"))
180 })
181 t.Run("exclude_usingother", func(t *testing.T) {
182 t.Parallel()
183 runDiffTest(t, "testdata/nesting", "usingother.exclude.txtar", WithExcludeTypes("pkg.Baz"))
184 })
185
186 t.Run("mixed", func(t *testing.T) {
187 t.Parallel()
188 runDiffTest(t, "testdata/nesting", "mixed.txtar", WithIncludeTypes("pkg.Foo", "pkg.FooEnum"), WithExcludeTypes("pkg.Foo.NestedFoo", "pkg.Baz"))
189 })
190
191 t.Run("include-excluded", func(t *testing.T) {
192 t.Parallel()
193 ctx := t.Context()
194 _, image, err := getImage(ctx, slogtestext.NewLogger(t), "testdata/nesting", bufimage.WithExcludeSourceCodeInfo())
195 require.NoError(t, err)
196 _, err = FilterImage(image, WithIncludeTypes("pkg.Foo.NestedFoo"), WithExcludeTypes("pkg.Foo"))

Callers

nothing calls this directly

Calls 8

NewLoggerFunction · 0.92
runDiffTestFunction · 0.85
WithIncludeTypesFunction · 0.85
WithExcludeTypesFunction · 0.85
getImageFunction · 0.85
FilterImageFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…