diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c7fca14..4c9e3fb 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,6 +17,7 @@ jobs: python -m pip install --upgrade pip pip install -r tests-requirements.txt pip install -r requirements.txt + sudo apt-get install shellcheck - name: Run tests run: | ./tests.sh diff --git a/catcli/noder.py b/catcli/noder.py index 996c733..c6390fe 100644 --- a/catcli/noder.py +++ b/catcli/noder.py @@ -322,11 +322,11 @@ class Noder: """ if not node: return - if node.type == node.TYPE_TOP: + if node.type == nodes.TYPE_TOP: return out = [] - if node.type == node.TYPE_STORAGE: + if node.type == nodes.TYPE_STORAGE: # handle storage out.append(node.name) # name out.append(node.type) # type @@ -357,7 +357,7 @@ class Noder: out.append(epoch_to_str(node.maccess)) # maccess else: out.append('') # fake maccess - if node.md5: + if self._has_attr(node, 'md5'): out.append(node.md5) # md5 else: out.append('') # fake md5 diff --git a/tests-ng/assets/github.catalog.csv.txt b/tests-ng/assets/github.catalog.csv.txt new file mode 100644 index 0000000..27c7f31 --- /dev/null +++ b/tests-ng/assets/github.catalog.csv.txt @@ -0,0 +1,5 @@ +"github","storage","","2380","2023-03-08 20:58:18","","","2","23343173632","245107195904","" +"workflows","dir","github/workflows","1190","2023-03-08 20:58:18","2023-03-02 10:15:30","","2","","","" +"pypi-release.yml","file","github/workflows/pypi-release.yml","691","2023-03-08 20:58:18","2022-10-19 21:00:37","57699a7a6a03e20e864f220e19f8e197","","","","" +"testing.yml","file","github/workflows/testing.yml","595","2023-03-08 20:58:18","2023-03-02 10:15:30","f4f4bc5acb9deae488b55f0c9c507120","","","","" +"FUNDING.yml","file","github/FUNDING.yml","17","2023-03-08 20:58:18","2022-10-19 21:00:37","0c6407a84d412c514007313fb3bca4de","","","","" diff --git a/tests-ng/assets/github.catalog.json b/tests-ng/assets/github.catalog.json index 6c5fbe7..339358b 100644 --- a/tests-ng/assets/github.catalog.json +++ b/tests-ng/assets/github.catalog.json @@ -5,7 +5,7 @@ "children": [ { "maccess": 1666206037.0786593, - "md5": null, + "md5": "0c6407a84d412c514007313fb3bca4de", "name": "FUNDING.yml", "relpath": "/FUNDING.yml", "size": 17, @@ -15,7 +15,7 @@ "children": [ { "maccess": 1666206037.078865, - "md5": null, + "md5": "57699a7a6a03e20e864f220e19f8e197", "name": "pypi-release.yml", "relpath": "workflows/pypi-release.yml", "size": 691, @@ -23,7 +23,7 @@ }, { "maccess": 1677748530.6920426, - "md5": null, + "md5": "f4f4bc5acb9deae488b55f0c9c507120", "name": "testing.yml", "relpath": "workflows/testing.yml", "size": 595, @@ -38,18 +38,18 @@ "type": "dir" } ], - "free": 23459602432, + "free": 23343173632, "name": "github", "size": 2380, "total": 245107195904, - "ts": 1678214993, + "ts": 1678305498, "type": "storage" }, { "attr": { - "access": 1678214993, + "access": 1678305498, "access_version": "0.8.7", - "created": 1678214993, + "created": 1678305498, "created_version": "0.8.7" }, "name": "meta", diff --git a/tests-ng/assets/github.catalog.native.txt b/tests-ng/assets/github.catalog.native.txt new file mode 100644 index 0000000..40f187e --- /dev/null +++ b/tests-ng/assets/github.catalog.native.txt @@ -0,0 +1,7 @@ +top +└── storage: github + nbfiles:2 | totsize:2380 | free:9.5% | du:221764022272/245107195904 | date:2023-03-08 20:58:18 + ├── workflows [nbfiles:2, totsize:1190] + │ ├── pypi-release.yml [size:691, md5:57699a7a6a03e20e864f220e19f8e197] + │ └── testing.yml [size:595, md5:f4f4bc5acb9deae488b55f0c9c507120] + └── FUNDING.yml [size:17, md5:0c6407a84d412c514007313fb3bca4de] diff --git a/tests-ng/compare.sh b/tests-ng/compare.sh index 2c6289d..7b92d87 100755 --- a/tests-ng/compare.sh +++ b/tests-ng/compare.sh @@ -49,11 +49,18 @@ clear_on_exit "${tmpd}" catalog="${tmpd}/catalog" # index -${bin} -B index --catalog="${catalog}" github .github - -# diff +${bin} -B index -c --catalog="${catalog}" github .github cat "${catalog}" -diff "${cur}/assets/github.catalog.json" "${catalog}" + +# make sure we still get the same output in native format +native="${tmpd}/native.txt" +${bin} -B ls -r -s --format=native --catalog="${catalog}" > "${native}" +diff -I '^.*| totsize.*$' "${cur}/assets/github.catalog.native.txt" "${native}" + +# make sure we still get the same output in csv +csv="${tmpd}/csv.txt" +${bin} -B ls -r -s --format=csv --catalog="${catalog}" > "${csv}" +diff -I '^.*| totsize.*$' "${cur}/assets/github.catalog.csv.txt" "${csv}" # the end echo "test \"$(basename "$0")\" success"