Skip to content

Commit

Permalink
fix: error on oci_concurrency (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanHoladay committed Jul 23, 2024
1 parent f6360e5 commit 7e774a0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ const (
architecture configOption = "architecture"
noLogFile configOption = "no_log_file"
noProgress configOption = "no_progress"
noColor configOption = "no_color"
ociConcurrency configOption = "oci_concurrency"
)

// isValidConfigOption checks if a string is a valid config option
func isValidConfigOption(str string) bool {
switch configOption(str) {
case confirm, insecure, cachePath, tempDirectory, logLevelOption, architecture, noLogFile, noProgress:
case confirm, insecure, cachePath, tempDirectory, logLevelOption, architecture, noLogFile, noProgress, noColor, ociConcurrency:
return true
default:
return false
Expand Down
34 changes: 34 additions & 0 deletions src/cmd/common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestValidConfigOptions(t *testing.T) {
options := []string{
"confirm",
"insecure",
"uds_cache",
"tmp_dir",
"log_level",
"architecture",
"no_log_file",
"no_progress",
"oci_concurrency",
"no_color",
}

for _, option := range options {
t.Run("test-"+option, func(t *testing.T) {
res := isValidConfigOption(option)
require.True(t, res)
})
}

t.Run("test-invalid-option", func(t *testing.T) {
res := isValidConfigOption("invalid")
require.False(t, res)
})
}
2 changes: 1 addition & 1 deletion src/cmd/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestValidateDevDeployFlags(t *testing.T) {
DevDeployOpts: types.BundleDevDeployOptions{
Ref: map[string]string{"some-key": "some-ref"},
},
expectError: true,
expectError: false,
},
{
name: "Remote bundle with --ref flag",
Expand Down
5 changes: 4 additions & 1 deletion tasks/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ tasks:
- name: unit
description: run all the unit tests
actions:
- cmd: cd src/pkg && go test ./... -failfast -v -timeout 5m
- cmd: go test ./... -failfast -v -timeout 5m
dir: src/pkg
- cmd: go test ./... -failfast -v -timeout 5m
dir: src/cmd

- name: e2e-ghcr
description: run e2e tests that write to GHCR
Expand Down

0 comments on commit 7e774a0

Please sign in to comment.