github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/helper/oneline/read_test.go (about) 1 package oneline 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestRead(t *testing.T) { 9 cases := []struct { 10 Name string 11 Expected string 12 Err bool 13 }{ 14 { 15 "basic.txt", 16 "foo", 17 false, 18 }, 19 20 { 21 "oneline.txt", 22 "bar", 23 false, 24 }, 25 } 26 27 for _, tc := range cases { 28 actual, err := Read(filepath.Join("test-fixtures", tc.Name)) 29 if (err != nil) != tc.Err { 30 t.Fatalf("%s, err: %s", tc.Name, err) 31 } 32 33 if actual != tc.Expected { 34 t.Fatalf("%s, mismatch: %s != %s", tc.Name, actual, tc.Expected) 35 } 36 } 37 }