github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/protoc/intent_test.go (about)

     1  package protoc
     2  
     3  import "testing"
     4  
     5  func TestParseIntent(t *testing.T) {
     6  	for name, tc := range map[string]struct {
     7  		in        string
     8  		wantValue string
     9  		want      bool
    10  	}{
    11  		"": {
    12  			in:        "",
    13  			wantValue: "",
    14  			want:      true,
    15  		},
    16  		"bare": {
    17  			in:        "foo",
    18  			wantValue: "foo",
    19  			want:      true,
    20  		},
    21  		"+": {
    22  			in:        "+foo",
    23  			wantValue: "foo",
    24  			want:      true,
    25  		},
    26  		"-": {
    27  			in:        "-foo",
    28  			wantValue: "foo",
    29  			want:      false,
    30  		},
    31  	} {
    32  		t.Run(name, func(t *testing.T) {
    33  			intent := parseIntent(tc.in)
    34  			if tc.wantValue != intent.Value {
    35  				t.Errorf("value: want %s, got %s", tc.wantValue, intent.Value)
    36  			}
    37  			if tc.want != intent.Want {
    38  				t.Errorf("value: want %t, got %t", tc.want, intent.Want)
    39  			}
    40  		})
    41  	}
    42  }