github.com/prebid/prebid-server/v2@v2.18.0/errortypes/scope_test.go (about)

     1  package errortypes
     2  
     3  import (
     4  	"errors"
     5  	"testing"
     6  )
     7  
     8  func TestReadScope(t *testing.T) {
     9  	tests := []struct {
    10  		name string
    11  		err  error
    12  		want Scope
    13  	}{
    14  		{
    15  			name: "scope-debug",
    16  			err:  &DebugWarning{Message: "scope is debug"},
    17  			want: ScopeDebug,
    18  		},
    19  		{
    20  			name: "scope-any",
    21  			err:  &Warning{Message: "scope is any"},
    22  			want: ScopeAny,
    23  		},
    24  		{
    25  			name: "default-error",
    26  			err:  errors.New("default error"),
    27  			want: ScopeAny,
    28  		},
    29  	}
    30  	for _, tt := range tests {
    31  		t.Run(tt.name, func(t *testing.T) {
    32  			if got := ReadScope(tt.err); got != tt.want {
    33  				t.Errorf("ReadScope() = %v, want %v", got, tt.want)
    34  			}
    35  		})
    36  	}
    37  }