gitlab.com/gitlab-org/labkit@v1.21.0/errortracking/tracker_options_test.go (about)

     1  package errortracking
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  )
     8  
     9  func Test_applyTrackerOptions(t *testing.T) {
    10  	tests := []struct {
    11  		name string
    12  		opts []TrackerOption
    13  		want trackerConfig
    14  	}{
    15  		{
    16  			name: "with-all-options",
    17  			opts: []TrackerOption{
    18  				WithSentryDSN("dsn"),
    19  				WithVersion("ver"),
    20  				WithSentryEnvironment("env"),
    21  				WithLoggerName("test-logger"),
    22  			},
    23  			want: trackerConfig{
    24  				sentryDSN:         "dsn",
    25  				version:           "ver",
    26  				sentryEnvironment: "env",
    27  				loggerName:        "test-logger",
    28  			},
    29  		},
    30  	}
    31  	for _, tt := range tests {
    32  		t.Run(tt.name, func(t *testing.T) {
    33  			got := applyTrackerOptions(tt.opts)
    34  
    35  			require.Equalf(t, got, tt.want, "applyTrackerOptions() = %v, want %v", got, tt.want)
    36  		})
    37  	}
    38  }