github.com/Azure/aad-pod-identity@v1.8.17/pkg/log/options_test.go (about)

     1  package log
     2  
     3  import "testing"
     4  
     5  func TestValidate(t *testing.T) {
     6  	cases := []struct {
     7  		logFormat     string
     8  		expectedError bool
     9  	}{
    10  		{
    11  			logFormat:     textLogFormat,
    12  			expectedError: false,
    13  		},
    14  		{
    15  			logFormat:     jsonLogFormat,
    16  			expectedError: false,
    17  		},
    18  		{
    19  			logFormat:     "unknown",
    20  			expectedError: true,
    21  		},
    22  	}
    23  
    24  	for _, tc := range cases {
    25  		o := Options{
    26  			LogFormat: tc.logFormat,
    27  		}
    28  
    29  		err := o.Validate()
    30  		if err != nil && !tc.expectedError {
    31  			t.Errorf("expected no error, but got %+v", err)
    32  		}
    33  		if err == nil && tc.expectedError {
    34  			t.Errorf("expected an error to occur, but got nil")
    35  		}
    36  	}
    37  }