github.com/haraldrudell/parl@v0.4.176/perrors/errorglue/warning_test.go (about)

     1  /*
     2  © 2021–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package errorglue
     7  
     8  import (
     9  	"errors"
    10  	"strings"
    11  	"testing"
    12  )
    13  
    14  func TestNewWarning(t *testing.T) {
    15  	message := "message"
    16  	w := "warning:"
    17  
    18  	warning := NewWarning(errors.New(message))
    19  	if !strings.Contains(warning.Error(), w) {
    20  		t.Errorf("Warning.Error %q missing %q", warning.Error(), w)
    21  	}
    22  	if !strings.Contains(warning.Error(), message) {
    23  		t.Errorf("Warning.Error %q missing %q", warning.Error(), message)
    24  	}
    25  	if _, ok := warning.(*WarningType); !ok {
    26  		t.Error("Warning not WarningType")
    27  	}
    28  }