github.com/xmidt-org/webpa-common@v1.11.9/xhttp/fanout/result_test.go (about)

     1  package fanout
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func testDefaultShouldTerminate(t *testing.T, statusCode int, expected bool) {
    11  	assert := assert.New(t)
    12  	assert.Equal(
    13  		expected,
    14  		DefaultShouldTerminate(Result{StatusCode: statusCode}),
    15  	)
    16  }
    17  
    18  func TestDefaultShouldTerminate(t *testing.T) {
    19  	testData := []struct {
    20  		StatusCode int
    21  		Expected   bool
    22  	}{
    23  		{200, true},
    24  		{201, true},
    25  		{202, true},
    26  		{400, false},
    27  		{404, false},
    28  		{500, false},
    29  		{503, false},
    30  		{504, false},
    31  	}
    32  
    33  	for _, record := range testData {
    34  		t.Run(fmt.Sprintf("StatusCode=%d", record.StatusCode), func(t *testing.T) {
    35  			testDefaultShouldTerminate(t, record.StatusCode, record.Expected)
    36  		})
    37  	}
    38  }