Skip to content

Commit

Permalink
test: add simplest test for ls
Browse files Browse the repository at this point in the history
# Motivation

Many top level commands are missing tests. This is
a first step to add a test for `ls` with proper
test data.

# Changes

This commit adds a very simple test for `ls` that
checks that it does not crash when reading a file.

# Future work

Add more checks to the test so that it is even
better at avoiding regressions.

# Acknowledgements

Thanks to Ilya Kreymer for providing the test data
through issue
#99
  • Loading branch information
trym-b committed Mar 25, 2024
1 parent 6786312 commit a16482e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.warc.gz filter=lfs diff=lfs merge=lfs -text
19 changes: 19 additions & 0 deletions cmd/ls/ls_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ls

import (
"path/filepath"
"testing"

"github.com/nlnwa/warchaeology/internal/filter"
"github.com/spf13/afero"
)

func TestConfigReadFileWithError(t *testing.T) {
testDataDir := filepath.Join("..", "..", "test-data")
warcWithErrors := filepath.Join(testDataDir, "samsung-with-error", "rec-33318048d933-20240317162652059-0.warc.gz")
config := &conf{}
config.filter = filter.NewFromViper()
config.files = []string{warcWithErrors}
_ = config.readFile(afero.NewOsFs(), warcWithErrors)
// TODO: check that the result contains the expected values
}
3 changes: 3 additions & 0 deletions test-data/samsung-with-error/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Origin

This file was provided by Ilya Kreymer through issue: https://github.com/nlnwa/warchaeology/issues/99#issuecomment-2012776966
Git LFS file not shown

0 comments on commit a16482e

Please sign in to comment.