-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #396 from gphotosuploader/issue-393
Add Album configuration option to set the Album target in Google Photos
- Loading branch information
Showing
24 changed files
with
293 additions
and
61 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 |
---|---|---|
|
@@ -63,14 +63,22 @@ func TestFromFile(t *testing.T) { | |
want string | ||
isErrExpected bool | ||
}{ | ||
{"Should success", "testdata/valid-config/config.hjson", "[email protected]", false}, | ||
{"Should fail if dir does not exist", "testdata/non-existent/config.hjson", "", true}, | ||
{"Should fail if Account is invalid", "testdata/invalid-config/Account.hjson", "", true}, | ||
{"Should fail if SourceFolder does not exist", "testdata/invalid-config/SourceFolder.hjson", "", true}, | ||
{"Should fail if SecretsBackendType is invalid", "testdata/invalid-config/SecretsBackendType.hjson", "", true}, | ||
{"Should fail if AppAPICredentials are invalid", "testdata/invalid-config/AppAPICredentials.hjson", "", true}, | ||
{"Should fail if CreateAlbums is invalid", "testdata/invalid-config/CreateAlbums.hjson", "", true}, | ||
{"Should success with Album's name option", "testdata/valid-config/configWithAlbumNameOption.hjson", "[email protected]", false}, | ||
{"Should success with Album's auto folderName option", "testdata/valid-config/configWithAlbumAutoFolderNameOption.hjson", "[email protected]", false}, | ||
{"Should success with Album's auto folderPath option", "testdata/valid-config/configWithAlbumAutoFolderPathOption.hjson", "[email protected]", false}, | ||
{"Should success with deprecated CreateAlbums option", "testdata/valid-config/configWithDeprecatedCreateAlbumsOption.hjson", "[email protected]", false}, | ||
|
||
{"Should fail if config dir does not exist", "testdata/non-existent/config.hjson", "", true}, | ||
{"Should fail if Account is invalid", "testdata/invalid-config/EmptyAccount.hjson", "", true}, | ||
{"Should fail if SourceFolder does not exist", "testdata/invalid-config/NonExistentSourceFolder.hjson", "", true}, | ||
{"Should fail if SecretsBackendType is invalid", "testdata/invalid-config/BadSecretsBackendType.hjson", "", true}, | ||
{"Should fail if AppAPICredentials are invalid", "testdata/invalid-config/EmptyAppAPICredentials.hjson", "", true}, | ||
{"Should fail if Jobs is empty", "testdata/invalid-config/NoJobs.hjson", "", true}, | ||
{"Should fail if Album's format is invalid", "testdata/invalid-config/AlbumBadFormat.hjson", "", true}, | ||
{"Should fail if Album's key is invalid", "testdata/invalid-config/AlbumBadKey.hjson", "", true}, | ||
{"Should fail if Album's name is invalid", "testdata/invalid-config/AlbumEmptyName.hjson", "", true}, | ||
{"Should fail if Album's auto value is invalid", "testdata/invalid-config/AlbumBadAutoValue.hjson", "", true}, | ||
{"Should fail if deprecated CreateAlbums is invalid", "testdata/invalid-config/DeprecatedCreateAlbums.hjson", "", true}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
|
@@ -100,14 +108,15 @@ func TestConfig_SafePrint(t *testing.T) { | |
Jobs: []config.FolderUploadJob{ | ||
{ | ||
SourceFolder: "foo", | ||
Album: "name:albumName", | ||
CreateAlbums: "folderPath", | ||
DeleteAfterUpload: false, | ||
IncludePatterns: []string{}, | ||
ExcludePatterns: []string{}, | ||
}, | ||
}, | ||
} | ||
want := `{"APIAppCredentials":{"ClientID":"client-id","ClientSecret":"REMOVED"},"Account":"account","SecretsBackendType":"auto","Jobs":[{"SourceFolder":"foo","CreateAlbums":"folderPath","DeleteAfterUpload":false,"IncludePatterns":[],"ExcludePatterns":[]}]}` | ||
want := `{"APIAppCredentials":{"ClientID":"client-id","ClientSecret":"REMOVED"},"Account":"account","SecretsBackendType":"auto","Jobs":[{"SourceFolder":"foo","Album":"name:albumName","CreateAlbums":"folderPath","DeleteAfterUpload":false,"IncludePatterns":[],"ExcludePatterns":[]}]}` | ||
|
||
if want != cfg.SafePrint() { | ||
t.Errorf("want: %s, got: %s", want, cfg.SafePrint()) | ||
|
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata | ||
Album: auto:invalid | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
internal/config/testdata/invalid-config/AlbumBadFormat.hjson
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata | ||
Album: invalid | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata | ||
Album: invalid:fooBar | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
internal/config/testdata/invalid-config/AlbumEmptyName.hjson
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata | ||
Album: name: | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
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
File renamed without changes.
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
19 changes: 19 additions & 0 deletions
19
internal/config/testdata/valid-config/configWithAlbumAutoFolderNameOption.hjson
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata/valid-config | ||
Album: auto:folderName | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
internal/config/testdata/valid-config/configWithAlbumAutoFolderPathOption.hjson
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,19 @@ | ||
{ | ||
APIAppCredentials: | ||
{ | ||
ClientID: client-id | ||
ClientSecret: client-secret | ||
} | ||
Account: [email protected] | ||
SecretsBackendType: auto | ||
Jobs: | ||
[ | ||
{ | ||
SourceFolder: ./testdata/valid-config | ||
Album: name:albumName | ||
DeleteAfterUpload: false | ||
IncludePatterns: [] | ||
ExcludePatterns: [] | ||
} | ||
] | ||
} |
Oops, something went wrong.