zenity/file_test.go
2020-01-03 01:44:23 +00:00

57 lines
1.2 KiB
Go

package zenity
import "testing"
const defaultPath = ""
func TestSelectFile(t *testing.T) {
res, err := SelectFile(Filename(defaultPath), FileFilters{
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
}.New())
if err != nil {
t.Error(err)
} else {
t.Logf("%#v", res)
}
}
func TestSelectFileMutiple(t *testing.T) {
res, err := SelectFileMutiple(Filename(defaultPath), FileFilters{
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
}.New())
if err != nil {
t.Error(err)
} else {
t.Logf("%#v", res)
}
}
func TestSelectFileSave(t *testing.T) {
res, err := SelectFileSave(Filename(defaultPath), ConfirmOverwrite, FileFilters{
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
}.New())
if err != nil {
t.Error(err)
} else {
t.Logf("%#v", res)
}
}
func TestSelectDirectory(t *testing.T) {
res, err := SelectDirectory(Filename(defaultPath))
if err != nil {
t.Error(err)
} else {
t.Logf("%#v", res)
}
}