Skip to content

Commit

Permalink
Merge pull request #2245 from keshavdalmia10/cache_flag_case_sensitiv…
Browse files Browse the repository at this point in the history
…ity_2229

handled case sensitivity
  • Loading branch information
natalieparellano authored Sep 10, 2024
2 parents 3a22a7f + 0927dde commit 86b4bf3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cache/cache_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c *CacheOpts) Set(value string) error {
return errors.Errorf("invalid field '%s' must be a key=value pair", field)
}
key := strings.ToLower(parts[0])
value := strings.ToLower(parts[1])
value := parts[1]
if key == "type" {
switch value {
case "build":
Expand All @@ -86,7 +86,7 @@ func (c *CacheOpts) Set(value string) error {
return errors.Errorf("invalid field '%s' must be a key=value pair", field)
}
key := strings.ToLower(parts[0])
value := strings.ToLower(parts[1])
value := parts[1]
switch key {
case "format":
switch value {
Expand Down
21 changes: 21 additions & 0 deletions pkg/cache/cache_opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ func testCacheOpts(t *testing.T, when spec.G, it spec.S) {
input: fmt.Sprintf("type=launch;format=bind;source=%s/test-bind-volume-cache", homeDir),
output: fmt.Sprintf("type=build;format=volume;type=launch;format=bind;source=%s/test-bind-volume-cache/launch-cache;", homeDir),
},
{
name: "Case sensitivity test with uppercase path",
input: fmt.Sprintf("type=build;format=bind;source=%s/TestBindBuildCache", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s/TestBindBuildCache/build-cache;type=launch;format=volume;", homeDir),
},
{
name: "Case sensitivity test with mixed case path",
input: fmt.Sprintf("type=build;format=bind;source=%s/TeStBiNdBuildCaChe", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s/TeStBiNdBuildCaChe/build-cache;type=launch;format=volume;", homeDir),
},
}
} else {
testcases = []CacheOptTestCase{
Expand All @@ -253,6 +263,17 @@ func testCacheOpts(t *testing.T, when spec.G, it spec.S) {
input: fmt.Sprintf("type=launch;format=bind;source=%s\\test-bind-volume-cache", homeDir),
output: fmt.Sprintf("type=build;format=volume;type=launch;format=bind;source=%s\\test-bind-volume-cache\\launch-cache;", homeDir),
},
// Case sensitivity test cases for Windows
{
name: "Case sensitivity test with uppercase path",
input: fmt.Sprintf("type=build;format=bind;source=%s\\TestBindBuildCache", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s\\TestBindBuildCache\\build-cache;type=launch;format=volume;", homeDir),
},
{
name: "Case sensitivity test with mixed case path",
input: fmt.Sprintf("type=build;format=bind;source=%s\\TeStBiNdBuildCaChe", homeDir),
output: fmt.Sprintf("type=build;format=bind;source=%s\\TeStBiNdBuildCaChe\\build-cache;type=launch;format=volume;", homeDir),
},
}
}

Expand Down

0 comments on commit 86b4bf3

Please sign in to comment.