go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/proto/protowalk/processor_deprecated_test.go (about)

     1  // Copyright 2022 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package protowalk
    16  
    17  import (
    18  	"testing"
    19  
    20  	. "github.com/smartystreets/goconvey/convey"
    21  )
    22  
    23  func TestDeprecated(t *testing.T) {
    24  	t.Parallel()
    25  
    26  	Convey(`Deprecated field check`, t, func() {
    27  		msg := &Outer{
    28  			Deprecated: "hey",
    29  			SingleInner: &Inner{
    30  				Regular:    "things",
    31  				Deprecated: "yo",
    32  			},
    33  			MapInner: map[string]*Inner{
    34  				"schwoot": {
    35  					Deprecated: "thing",
    36  					SingleEmbed: &Inner_Embedded{
    37  						Deprecated: "yarp",
    38  					},
    39  					MultiEmbed: []*Inner_Embedded{
    40  						{Deprecated: "yay"},
    41  						{Regular: "ignore"},
    42  					},
    43  					Recursive: &Inner_Recursive{
    44  						Regular: 1,
    45  						Next: &Inner_Recursive{
    46  							Regular: 2,
    47  						},
    48  					},
    49  				},
    50  			},
    51  			MultiDeprecated: []*Inner{
    52  				{Regular: "something"},
    53  				{Deprecated: "something else"},
    54  			},
    55  		}
    56  		So(Fields(msg, &DeprecatedProcessor{}).Strings(), ShouldResemble, []string{
    57  			`.deprecated: deprecated`,
    58  			`.single_inner.deprecated: deprecated`,
    59  			`.map_inner["schwoot"].deprecated: deprecated`,
    60  			`.map_inner["schwoot"].single_embed.deprecated: deprecated`,
    61  			`.map_inner["schwoot"].multi_embed[0].deprecated: deprecated`,
    62  			`.map_inner["schwoot"].recursive: deprecated`,
    63  			`.multi_deprecated: deprecated`,
    64  			`.multi_deprecated[1].deprecated: deprecated`,
    65  		})
    66  	})
    67  }