// TestSelectFile checks that the browser's index will be on a selected file
// if the filepath matches an existing file.
TestSelectFile checks that the browser's index will be on a selected file
if the filepath matches an existing file.
// TestSelectFile checks that the browser ' s index will be on a selected file // if the filepath matches an existing file .
func TestSelectFile(t *testing.T) {
	tempDir := t.TempDir()
	for _, ext := range []string{"jpg", "gif", "png", "JPEG"} {
		pattern := fmt.Sprintf("*.%s", ext)
		_, err := ioutil.TempFile(tempDir, pattern)
		if err != nil {
			panic(err)
		}
	}
	tempFile, err := ioutil.TempFile(tempDir, "my-file-*.jpg")
	if err != nil {
		panic(err)
	}
	browser, err := NewFileBrowser(tempFile.Name(), imageExtensions)
	if err != nil {
		t.Fatalf(`err = %v, want nil`, err)
	}
	absTempFile, err := filepath.Abs(tempFile.Name())
	if err != nil {
		panic(err)
	}
	absCurrentFile, err := filepath.Abs(browser.Current())
	if err != nil {
		panic(err)
	}
	if absTempFile != absCurrentFile {
		t.Errorf(`%q is current file, want %q`, absCurrentFile, absTempFile)
	}
}
func TestSelectFile ( t * testing . T ) { tempDir := t . TempDir ( ) for _ , ext := range [ ] string { " " , " " , " " , " " } { pattern := fmt . Sprintf ( " " , ext ) _ , err := ioutil . TempFile ( tempDir , pattern ) if err != nil { panic ( err ) } } tempFile , err := ioutil . TempFile ( tempDir , " " ) if err != nil { panic ( err ) } browser , err := NewFileBrowser ( tempFile . Name ( ) , imageExtensions ) if err != nil { t . Fatalf ( `err = %v, want nil` , err ) } absTempFile , err := filepath . Abs ( tempFile . Name ( ) ) if err != nil { panic ( err ) } absCurrentFile , err := filepath . Abs ( browser . Current ( ) ) if err != nil { panic ( err ) } if absTempFile != absCurrentFile { t . Errorf ( `%q is current file, want %q` , absCurrentFile , absTempFile ) } }
TestSelectFile checks that the browser's index will be on a selected file
if the filepath matches an existing file.
TestSelectFile checks that the browser ' s index will be on a selected file if the filepath matches an existing file .