...

Source file src/github.com/ory/go-convenience/stringsx/coalesce_test.go

Documentation: github.com/ory/go-convenience/stringsx

     1  package stringsx
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestCoalesce(t *testing.T) {
    11  	for k, tc := range []struct {
    12  		in     []string
    13  		expect string
    14  	}{
    15  		{
    16  			in:     []string{"", "", "foo"},
    17  			expect: "foo",
    18  		},
    19  		{
    20  			in:     []string{"bar", "", "foo"},
    21  			expect: "bar",
    22  		},
    23  	} {
    24  		t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
    25  			assert.EqualValues(t, tc.expect, Coalesce(tc.in...))
    26  		})
    27  	}
    28  }
    29  

View as plain text