github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/appfile/customization_test.go (about)

     1  package appfile
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestCustomizationSetFilter(t *testing.T) {
     9  	cases := []struct {
    10  		Raw        []*Customization
    11  		FilterType string
    12  		Result     []*Customization
    13  	}{
    14  		{
    15  			[]*Customization{
    16  				&Customization{Type: "foo"},
    17  				&Customization{Type: "bar"},
    18  			},
    19  			"foo",
    20  			[]*Customization{
    21  				&Customization{Type: "foo"},
    22  			},
    23  		},
    24  
    25  		{
    26  			[]*Customization{
    27  				&Customization{Type: "foo"},
    28  				&Customization{Type: "bar"},
    29  			},
    30  			"fOo",
    31  			[]*Customization{
    32  				&Customization{Type: "foo"},
    33  			},
    34  		},
    35  	}
    36  
    37  	for i, tc := range cases {
    38  		set := &CustomizationSet{Raw: tc.Raw}
    39  		actual := set.Filter(tc.FilterType)
    40  		if !reflect.DeepEqual(actual, tc.Result) {
    41  			t.Fatalf("bad %d:\n\n%#v\n\n%#v", i, actual, tc.Result)
    42  		}
    43  	}
    44  }