Skip to content

Commit

Permalink
handled case sensitivity
Browse files Browse the repository at this point in the history
Signed-off-by: Keshav Dalmia <[email protected]>
  • Loading branch information
keshav authored and keshavdalmia10 committed Aug 9, 2024
1 parent 5d0687f commit 1e26662
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 1e26662

Please sign in to comment.