github.com/humans-group/gqlgen@v0.7.2/internal/imports/prune_test.go (about) 1 package imports 2 3 import ( 4 "io/ioutil" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestPrune(t *testing.T) { 11 b, err := Prune("testdata/unused.go", mustReadFile("testdata/unused.go")) 12 require.NoError(t, err) 13 require.Equal(t, string(mustReadFile("testdata/unused.expected.go")), string(b)) 14 } 15 16 func mustReadFile(filename string) []byte { 17 b, err := ioutil.ReadFile(filename) 18 if err != nil { 19 panic(err) 20 } 21 return b 22 }