-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9050b07
commit 33de138
Showing
2 changed files
with
53 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/defenseunicorns/uds-cli/src/config" | ||
"github.com/defenseunicorns/uds-cli/src/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSettingArchitecture(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
cliArch string | ||
bundle *types.UDSBundle | ||
expectedVal string | ||
}{ | ||
{ | ||
name: "CLIArch takes precedence", | ||
cliArch: "archFromFlag", | ||
bundle: &types.UDSBundle{ | ||
Metadata: types.UDSMetadata{ | ||
Architecture: "setFromMetadata", | ||
}, | ||
}, | ||
expectedVal: "archFromFlag", | ||
}, | ||
{ | ||
name: "Metadata.Arch", | ||
cliArch: "", | ||
bundle: &types.UDSBundle{ | ||
Metadata: types.UDSMetadata{ | ||
Architecture: "setFromMetadata", | ||
}, | ||
}, | ||
expectedVal: "setFromMetadata", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
b := tc.bundle | ||
config.CLIArch = tc.cliArch | ||
b.Build.Architecture = config.GetArch(b.Metadata.Architecture) | ||
require.Equal(t, tc.expectedVal, b.Build.Architecture) | ||
}) | ||
} | ||
} |