mirror of
https://github.com/walles/moar.git
synced 2024-10-05 16:07:54 +03:00
Add (failing) compressed-files tests
This commit is contained in:
parent
70500056af
commit
e640c7d856
@ -73,6 +73,8 @@ func (p *_Pager) Quit() {
|
||||
}
|
||||
|
||||
func (p *_Pager) _OnKey(logger *log.Logger, key tcell.Key) {
|
||||
// FIXME: Add support for pressing 'h' to get a list of keybindings
|
||||
// FIXME: Add support for pressing '/' to search
|
||||
switch key {
|
||||
case tcell.KeyEscape:
|
||||
p.Quit()
|
||||
|
@ -69,16 +69,18 @@ func _TestGetLines(t *testing.T, reader *Reader) {
|
||||
}
|
||||
}
|
||||
|
||||
func _GetTestFiles() []string {
|
||||
func _GetSamplesDir() string {
|
||||
// From: https://coderwall.com/p/_fmbug/go-get-path-to-current-file
|
||||
_, filename, _, ok := runtime.Caller(0)
|
||||
if !ok {
|
||||
panic("Getting current filename failed")
|
||||
}
|
||||
|
||||
samplesDir := path.Join(path.Dir(filename), "../sample-files")
|
||||
return path.Join(path.Dir(filename), "../sample-files")
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(samplesDir)
|
||||
func _GetTestFiles() []string {
|
||||
files, err := ioutil.ReadDir(_GetSamplesDir())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -135,6 +137,18 @@ func TestStatusText(t *testing.T) {
|
||||
assert.Equal(t, statusText, "null: <empty>")
|
||||
}
|
||||
|
||||
// FIXME: Add test for opening .gz files
|
||||
// FIXME: Add test for opening .xz files
|
||||
// FIXME: Add test for opening .bz2 files
|
||||
func _TestCompressedFile(t *testing.T, filename string) {
|
||||
reader, e := NewReaderFromFilename(_GetSamplesDir() + "/" + filename)
|
||||
if e != nil {
|
||||
t.Errorf("Error opening file <%s>: %s", filename, e.Error())
|
||||
panic(e)
|
||||
}
|
||||
|
||||
assert.Equal(t, reader.GetLines(1, 5).lines, [...]string{"This is a compressed file"})
|
||||
}
|
||||
|
||||
func TestCompressedFiles(t *testing.T) {
|
||||
_TestCompressedFile(t, "compressed.gz")
|
||||
_TestCompressedFile(t, "compressed.bz2")
|
||||
_TestCompressedFile(t, "compressed.xz")
|
||||
}
|
||||
|
BIN
sample-files/compressed.txt.bz2
Normal file
BIN
sample-files/compressed.txt.bz2
Normal file
Binary file not shown.
BIN
sample-files/compressed.txt.gz
Normal file
BIN
sample-files/compressed.txt.gz
Normal file
Binary file not shown.
BIN
sample-files/compressed.txt.xz
Normal file
BIN
sample-files/compressed.txt.xz
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user