|
| 1 | +package xcodebuild |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/stretchr/testify/require" |
| 7 | +) |
| 8 | + |
| 9 | +func TestExportCommandModel_cmdSlice(t *testing.T) { |
| 10 | + tests := []struct { |
| 11 | + name string |
| 12 | + archivePath string |
| 13 | + exportDir string |
| 14 | + exportOptionsPlist string |
| 15 | + authentication *AuthenticationParams |
| 16 | + want []string |
| 17 | + }{ |
| 18 | + { |
| 19 | + name: "basic export", |
| 20 | + archivePath: "sample.xcarchive", |
| 21 | + exportDir: "/var/exported", |
| 22 | + exportOptionsPlist: "/var/export_options.plist", |
| 23 | + want: []string{"xcodebuild", |
| 24 | + "-exportArchive", |
| 25 | + "-archivePath", "sample.xcarchive", |
| 26 | + "-exportPath", "/var/exported", |
| 27 | + "-exportOptionsPlist", "/var/export_options.plist", |
| 28 | + }, |
| 29 | + }, |
| 30 | + { |
| 31 | + name: "export with authentication", |
| 32 | + archivePath: "sample.xcarchive", |
| 33 | + authentication: &AuthenticationParams{ |
| 34 | + KeyID: "keyID", |
| 35 | + IsssuerID: "issuerID", |
| 36 | + KeyPath: "/key/path", |
| 37 | + }, |
| 38 | + want: []string{"xcodebuild", |
| 39 | + "-exportArchive", |
| 40 | + "-archivePath", "sample.xcarchive", |
| 41 | + "-allowProvisioningUpdates", |
| 42 | + "-authenticationKeyPath", "/key/path", |
| 43 | + "-authenticationKeyID", "keyID", |
| 44 | + "-authenticationKeyIssuerID", "issuerID", |
| 45 | + }, |
| 46 | + }, |
| 47 | + } |
| 48 | + for _, tt := range tests { |
| 49 | + t.Run(tt.name, func(t *testing.T) { |
| 50 | + c := NewExportCommand() |
| 51 | + c.SetArchivePath(tt.archivePath) |
| 52 | + c.SetExportDir(tt.exportDir) |
| 53 | + c.SetExportOptionsPlist(tt.exportOptionsPlist) |
| 54 | + if tt.authentication != nil { |
| 55 | + c.SetAuthentication(*tt.authentication) |
| 56 | + } |
| 57 | + |
| 58 | + got := c.cmdSlice() |
| 59 | + require.Equal(t, tt.want, got) |
| 60 | + |
| 61 | + got2 := c.cmdSlice() |
| 62 | + require.Equal(t, tt.want, got2, "Second run should return the same result") |
| 63 | + }) |
| 64 | + } |
| 65 | +} |
0 commit comments