github.com/quay/claircore@v1.5.28/test/integration/poison_http_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"context"
     5  	"net/http"
     6  	"testing"
     7  )
     8  
     9  func TestPoison(t *testing.T) {
    10  	ctx := context.Background()
    11  	t.Run("Direct", func(t *testing.T) {
    12  		p := poisonedTransport("TEST")
    13  		_, err := p.DialContext(ctx, "tcp6", "::1")
    14  		if err == nil {
    15  			t.Errorf("expected error, got: %v", err)
    16  		}
    17  		t.Log(err)
    18  	})
    19  
    20  	t.Run("Client", func(t *testing.T) {
    21  		c := &http.Client{
    22  			Transport: poisonedTransport("TEST"),
    23  		}
    24  		_, err := c.Head("http://[::1]/")
    25  		if err == nil {
    26  			t.Errorf("expected error, got: %v", err)
    27  		}
    28  		t.Log(err)
    29  	})
    30  }