zenity/file_test.go

58 lines
1.2 KiB
Go
Raw Normal View History

2019-12-29 20:00:50 -05:00
package zenity
2019-12-11 05:29:31 -05:00
import "testing"
2019-12-28 10:34:38 -05:00
const defaultPath = ""
2019-12-29 20:00:50 -05:00
func TestSelectFile(t *testing.T) {
res, err := SelectFile("", defaultPath, []FileFilter{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2019-12-11 05:29:31 -05:00
})
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectFileMutiple(t *testing.T) {
res, err := SelectFileMutiple("", defaultPath, []FileFilter{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2019-12-11 05:29:31 -05:00
})
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectFileSave(t *testing.T) {
res, err := SelectFileSave("", defaultPath, true, []FileFilter{
2019-12-11 05:29:31 -05:00
{"Go files", []string{".go"}},
{"Web files", []string{".html", ".js", ".css"}},
2019-12-13 21:16:06 -05:00
{"Image files", []string{".png", ".gif", ".ico", ".jpg", ".webp"}},
2019-12-11 05:29:31 -05:00
})
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}
2019-12-29 20:00:50 -05:00
func TestSelectDirectory(t *testing.T) {
res, err := SelectDirectory("", defaultPath)
2019-12-11 05:29:31 -05:00
if err != nil {
t.Error(err)
} else {
2019-12-13 21:16:06 -05:00
t.Logf("%#v", res)
2019-12-11 05:29:31 -05:00
}
}