-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an archive selector to Siegfried
Using the -zs flag will aloow users to specify which archive types Siegfried cracks open to identify the contents of.
- Loading branch information
1 parent
74a791a
commit 8bce6b7
Showing
5 changed files
with
234 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2020 Ross Spencer, Richard Lehane. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
// implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
// Satisfies the Parseable interface to enable Roy to process Wikidata | ||
// signatures into a Siegfried compatible identifier. | ||
|
||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// Valid archive UIDs. | ||
var proZipUID = "x-fmt/263" | ||
var locArcUID = "fdd000235" | ||
var mimeTarUID = "application/x-tar" | ||
var mimeWarcUID = "application/x-warc" | ||
var mimeGzipUID = "application/gzip" | ||
|
||
// Non-archive UID. | ||
var nonArcUID = "fmt/1000" | ||
|
||
// arcTest defines the structure needed for our table driven testing. | ||
type arcTest struct { | ||
filter string // The set of zip-type files to provide SetArchiveFilterPermissive(...) | ||
uid string // A UID (PUID, FDD) that identifies a zip-type file. | ||
result Archive // The anticipated result from our test. | ||
} | ||
|
||
// isArcTests provide us a slice of tests and results to loop through. | ||
var isArcTests = []arcTest{ | ||
// Positive tests should return valid Archive values. | ||
arcTest{ListAllArcTypes(), proZipUID, Zip}, | ||
arcTest{"TAR", mimeTarUID, Tar}, | ||
arcTest{"gZip", mimeGzipUID, Gzip}, | ||
arcTest{"warc,zip,tar", mimeWarcUID, WARC}, | ||
arcTest{"zip,arc", locArcUID, ARC}, | ||
|
||
// Negative tests should all return None. | ||
arcTest{"zip,arc", mimeWarcUID, None}, | ||
arcTest{"zip,arc", mimeGzipUID, None}, | ||
arcTest{ListAllArcTypes(), nonArcUID, None}, | ||
arcTest{"", nonArcUID, None}, | ||
} | ||
|
||
// TestIsArchivePositive tests cases where the filter should return a | ||
// positive match. | ||
func TestIsArchivePositive(t *testing.T) { | ||
for _, test := range isArcTests { | ||
SetArchiveFilterPermissive(test.filter) | ||
arc := IsArchive(test.uid) | ||
if arc != test.result { | ||
t.Errorf( | ||
"Unexpected test result '%s', expected '%s'", | ||
arc, test.result, | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters