@@ -19,28 +19,30 @@ import (
1919
2020 "github.com/aep-dev/api-linter/rules/internal/testutils"
2121 "github.com/jhump/protoreflect/desc/builder"
22+ "google.golang.org/protobuf/types/descriptorpb"
2223)
2324
2425func TestSyntax (t * testing.T ) {
2526 // Set up the two permutations.
2627 tests := []struct {
2728 testName string
28- isProto3 bool
29+ edition descriptorpb. Edition
2930 problems testutils.Problems
3031 }{
31- {"Valid" , true , testutils.Problems {}},
32- {"Invalid" , false , testutils.Problems {{Suggestion : `syntax = "proto3";` }}},
32+ {"Valid (proto3)" , descriptorpb .Edition_EDITION_PROTO3 , testutils.Problems {}},
33+ {"Valid (2023)" , descriptorpb .Edition_EDITION_2023 , testutils.Problems {}},
34+ {"Valid (2024)" , descriptorpb .Edition_EDITION_2024 , testutils.Problems {}},
35+ {"Invalid (proto2)" , descriptorpb .Edition_EDITION_PROTO2 , testutils.Problems {{Suggestion : `edition = "2023";` }}},
3336 }
3437
3538 // Run each permutation as an individual test.
3639 for _ , test := range tests {
3740 t .Run (test .testName , func (t * testing.T ) {
3841 // Build an appropriate file descriptor.
39- f , err := builder .NewFile ("library.proto" ).SetProto3 (test .isProto3 ).Build ()
42+ f , err := builder .NewFile ("library.proto" ).SetEdition (test .edition ).Build ()
4043 if err != nil {
4144 t .Fatalf ("Could not build file descriptor." )
4245 }
43-
4446 // Lint the file, and ensure we got the expected problems.
4547 if diff := test .problems .SetDescriptor (f ).Diff (syntax .Lint (f )); diff != "" {
4648 t .Error (diff )
0 commit comments