// TestBasicBrowserCreation checks that a file browser can be created with a
// directory where all the files are valid and should be read.
TestBasicBrowserCreation checks that a file browser can be created with a
directory where all the files are valid and should be read.
// TestBasicBrowserCreation checks that a file browser can be created with a // directory where all the files are valid and should be read .
func TestBasicBrowserCreation(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)
		}
	}
	browser, err := NewFileBrowser(tempDir, imageExtensions)
	if err != nil {
		t.Fatalf(`err = %v, want nil`, err)
	}
	if actual, want := len(browser.Filenames), 4; actual != want {
		t.Errorf(`got %d files, want %d`, actual, want)
	}
	if i := browser.index; i != 0 {
		t.Errorf(`browser.index = %d, want 0`, i)
	}
	if browser.IsEmpty() {
		t.Errorf(`IsEmpty() = true, want false`)
	}
}
func TestBasicBrowserCreation ( 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 ) , 4 ; actual != want { t . Errorf ( `got %d files, want %d` , actual , want ) } if i := browser . index ; i != 0 { t . Errorf ( `browser.index = %d, want 0` , i ) } if browser . IsEmpty ( ) { t . Errorf ( `IsEmpty() = true, want false` ) } }
TestBasicBrowserCreation checks that a file browser can be created with a
directory where all the files are valid and should be read.
TestBasicBrowserCreation checks that a file browser can be created with a directory where all the files are valid and should be read .