First working version
- Move from separate dirs for upload to a unified one (identify media/metadata files by file extension) - Prevent uploading when an import is already scheduled - Allow setting custom, parser-specific settings - Add CLI - Implement WebDAV upload - Implement checking of upload folders for uploadable contents Close #6, close #7, close #9, close #3, close #1, close #4
This commit is contained in:
@@ -23,8 +23,7 @@ func getTestConfig() MDWebDavUploaderConfig {
|
||||
panic("Test failure: Failed to create test dir")
|
||||
}
|
||||
|
||||
input.MetadataFolder = testDir
|
||||
input.MediaFolder = testDir
|
||||
input.UploadDir = testDir
|
||||
|
||||
return input
|
||||
|
||||
@@ -128,13 +127,13 @@ func TestValidateUploaderConfigAcceptsValidParser(t *testing.T) {
|
||||
}
|
||||
|
||||
// Test that ValidateConfig() fails on non-existent folder.
|
||||
func TestValidateUploaderConfigFailsOnInvalidMetadataFolder(t *testing.T) {
|
||||
func TestValidateUploaderConfigFailsOnInvalidUploadDir(t *testing.T) {
|
||||
|
||||
input := getTestConfig()
|
||||
input.MetadataFolder = "nonexistentfolder"
|
||||
input.UploadDir = "nonexistentfolder"
|
||||
_, err := ValidateConfig(input)
|
||||
if err == nil {
|
||||
t.Fatalf("ValidateConfig() does not return an error on an invalid metadata folder")
|
||||
t.Fatalf("ValidateConfig() does not return an error on an invalid upload folder")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -145,14 +144,14 @@ func TestWritingAndReadingConfigWorks(t *testing.T) {
|
||||
input := getTestConfig()
|
||||
input, _ = ValidateConfig(input)
|
||||
|
||||
writeErr := StoreConfigToFile(input, input.MetadataFolder + "/config.json")
|
||||
writeErr := StoreConfigToFile(input, input.UploadDir + "/config.json")
|
||||
if writeErr != nil {
|
||||
t.Log("Error:")
|
||||
t.Log(writeErr)
|
||||
t.Fatalf("Failed to write config to override path")
|
||||
}
|
||||
|
||||
loadedFromFile, setupRequired, err := LoadFromFile(input.MetadataFolder + "/config.json")
|
||||
loadedFromFile, setupRequired, err := LoadFromFile(input.UploadDir + "/config.json")
|
||||
|
||||
if setupRequired != false {
|
||||
t.Fatalf("Expected no setup to be required, but return value indicated thus")
|
||||
@@ -161,7 +160,7 @@ func TestWritingAndReadingConfigWorks(t *testing.T) {
|
||||
t.Fatalf("Returned an error on trying to load config file")
|
||||
}
|
||||
// Golang can't compare structs with slices or maps
|
||||
if input.InstanceLink != loadedFromFile.InstanceLink || input.Mail != loadedFromFile.Mail || input.WebDavAuthToken != loadedFromFile.WebDavAuthToken || input.InstitutionId != loadedFromFile.InstitutionId || input.Parser != loadedFromFile.Parser || input.MetadataFolder != loadedFromFile.MetadataFolder || input.MediaFolder != loadedFromFile.MediaFolder || input.PublishOnImport != loadedFromFile.PublishOnImport {
|
||||
if input.InstanceLink != loadedFromFile.InstanceLink || input.Mail != loadedFromFile.Mail || input.WebDavAuthToken != loadedFromFile.WebDavAuthToken || input.InstitutionId != loadedFromFile.InstitutionId || input.Parser != loadedFromFile.Parser || input.UploadDir != loadedFromFile.UploadDir || input.PublishOnImport != loadedFromFile.PublishOnImport {
|
||||
t.Log("Input")
|
||||
t.Log(input)
|
||||
|
||||
|
Reference in New Issue
Block a user