-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
input deprecation & handle pipe and newline separated app lists (#52)
* input deprecation & handle pipe and newline separated app lists * PR fix * clear mapping file * PR fix * test update * app parsing fix and tests * app path split fix
- Loading branch information
Showing
4 changed files
with
146 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package main | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func Test_parseAppList(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
list string | ||
wantApps []string | ||
}{ | ||
{ | ||
name: "empty app list", | ||
list: "", | ||
wantApps: nil, | ||
}, | ||
{ | ||
name: "newline separated list", | ||
list: "app.apk\napp.aab\n \n", | ||
wantApps: []string{"app.apk", "app.aab"}, | ||
}, | ||
{ | ||
name: "pipe separated list", | ||
list: "|app.apk|app.aab|", | ||
wantApps: []string{"app.apk", "app.aab"}, | ||
}, | ||
{ | ||
name: "pipe and newline separated list", | ||
list: "\napp1.apk|app2.apk\napp.aab|", | ||
wantApps: []string{"app1.apk", "app2.apk", "app.aab"}, | ||
}, | ||
{ | ||
name: "pipe and newline separated list", | ||
list: "/bitrise/deploy/app-bitrise-signed.aab\n/bitrise/deploy/app.aab", | ||
wantApps: []string{"/bitrise/deploy/app-bitrise-signed.aab", "/bitrise/deploy/app.aab"}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if gotApps := parseAppList(tt.list); !reflect.DeepEqual(gotApps, tt.wantApps) { | ||
t.Errorf("parseAppList() = %v, want %v", gotApps, tt.wantApps) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestConfigs_appPaths(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
config Configs | ||
wantApps []string | ||
wantWarnings []string | ||
}{ | ||
{ | ||
name: "empty test", | ||
config: Configs{ | ||
AppPath: "", | ||
ApkPath: "", | ||
}, | ||
wantApps: nil, | ||
wantWarnings: nil, | ||
}, | ||
{ | ||
name: "prefers aab", | ||
config: Configs{ | ||
AppPath: "app.apk|app.aab", | ||
}, | ||
wantApps: []string{"app.aab"}, | ||
wantWarnings: []string{"Both .aab and .apk files provided, using the .aab file(s): app.aab"}, | ||
}, | ||
{ | ||
name: "uses deprecated input (ApkPath) if set", | ||
config: Configs{ | ||
AppPath: "app.aab", | ||
ApkPath: "app.apk", | ||
}, | ||
wantApps: []string{"app.apk"}, | ||
wantWarnings: []string{"step input 'APK file path' (apk_path) is deprecated and will be removed on 20 August 2019, use 'APK or App Bundle file path' (app_path) instead!"}, | ||
}, | ||
{ | ||
name: "uses first aab", | ||
config: Configs{ | ||
AppPath: "app.aab\napp1.aab", | ||
}, | ||
wantApps: []string{"app.aab"}, | ||
wantWarnings: []string{"More than 1 .aab files provided, using the first: app.aab"}, | ||
}, | ||
{ | ||
name: "unknown extension", | ||
config: Configs{ | ||
AppPath: "mapping.txt", | ||
}, | ||
wantApps: nil, | ||
wantWarnings: []string{"unknown app path extension in path: mapping.txt, supported extensions: .apk, .aab"}, | ||
}, | ||
{ | ||
name: "newline (\n) as a character", | ||
config: Configs{ | ||
AppPath: `/bitrise/deploy/app-bitrise-signed.aab\n/bitrise/deploy/app.aab`, | ||
}, | ||
wantApps: []string{"/bitrise/deploy/app-bitrise-signed.aab"}, | ||
wantWarnings: []string{"More than 1 .aab files provided, using the first: /bitrise/deploy/app-bitrise-signed.aab"}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotApps, gotWarnings := tt.config.appPaths() | ||
if !reflect.DeepEqual(gotApps, tt.wantApps) { | ||
t.Errorf("Configs.appPaths() gotApps = %v, want %v", gotApps, tt.wantApps) | ||
} | ||
if !reflect.DeepEqual(gotWarnings, tt.wantWarnings) { | ||
t.Errorf("Configs.appPaths() gotWarnings = %v, want %v", gotWarnings, tt.wantWarnings) | ||
} | ||
}) | ||
} | ||
} |
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