github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/synchronization/safety_test.go (about) 1 package synchronization 2 3 import ( 4 "testing" 5 ) 6 7 // TODO: Implement tests for additional functions. 8 9 // TestFilteredPathsAreSubset tests that filteredPathsAreSubset returns a 10 // correct assessment for a variety of test cases. 11 func TestFilteredPathsAreSubset(t *testing.T) { 12 // Set up test cases. 13 testCases := []struct { 14 filteredPaths []string 15 originalPaths []string 16 expected bool 17 }{ 18 {nil, nil, true}, 19 {nil, []string{}, true}, 20 {[]string{}, []string{}, true}, 21 {[]string{}, nil, true}, 22 {[]string{"a"}, []string{"a"}, true}, 23 {[]string{"a"}, []string{"a", "b"}, true}, 24 {[]string{"b"}, []string{"a", "b"}, true}, 25 {[]string{"c"}, nil, false}, 26 {[]string{"c"}, []string{}, false}, 27 {[]string{"c"}, []string{"a"}, false}, 28 {[]string{"c"}, []string{"a", "b"}, false}, 29 {[]string{"a", "b"}, []string{"a", "b"}, true}, 30 {[]string{"b", "a"}, []string{"a", "b"}, false}, 31 } 32 33 // Run test cases. 34 for c, testCase := range testCases { 35 if result := filteredPathsAreSubset( 36 testCase.filteredPaths, 37 testCase.originalPaths, 38 ); result != testCase.expected { 39 t.Errorf( 40 "result did not match expected for test case %d: %t != %t", 41 c, 42 result, 43 testCase.expected, 44 ) 45 } 46 } 47 }