// TestSkipUnsupported checks that a file browser will not include
// unsupported extensions.
TestSkipUnsupported checks that a file browser will not include
unsupported extensions.
// TestSkipUnsupported checks that a file browser will not include // unsupported extensions .
func TestSkipUnsupported(t *testing.T) {
	tempDir := t.TempDir()
	for _, ext := range []string{"jpg", "txt", "go"} {
		pattern := fmt.Sprintf("*.%s", ext)
		_, err := ioutil.TempFile(tempDir, pattern)
		if err != nil {
			panic(err)
		}
	}
	browser, err := NewFileBrowser(tempDir, imageExtensions)
	if err != nil {
		t.Fatalf(`err = %v, want nil`, err)
	}
	if actual, want := len(browser.Filenames), 1; actual != want {
		t.Errorf(`got %d files, want %d`, actual, want)
	}
	if actual, want := filepath.Ext(browser.Current()), ".jpg"; actual != want {
		t.Errorf(`file extension = %v, want %v`, actual, want)
	}
}
func TestSkipUnsupported ( t * testing . T ) { tempDir := t . TempDir ( ) for _ , ext := range [ ] string { " " , " " , " " } { pattern := fmt . Sprintf ( " " , ext ) _ , err := ioutil . TempFile ( tempDir , pattern ) if err != nil { panic ( err ) } } browser , err := NewFileBrowser ( tempDir , imageExtensions ) if err != nil { t . Fatalf ( `err = %v, want nil` , err ) } if actual , want := len ( browser . Filenames ) , 1 ; actual != want { t . Errorf ( `got %d files, want %d` , actual , want ) } if actual , want := filepath . Ext ( browser . Current ( ) ) , " " ; actual != want { t . Errorf ( `file extension = %v, want %v` , actual , want ) } }
TestSkipUnsupported checks that a file browser will not include
unsupported extensions.
TestSkipUnsupported checks that a file browser will not include unsupported extensions .