Skip to content

Commit 77613ab

Browse files
abushwangsondavidb
authored andcommitted
Add UT for "Support specifying content directory via root option"
Signed-off-by: abushwang <abushwang@tencent.com>
1 parent 6252bf7 commit 77613ab

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

soci/store/store_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package store
1818

1919
import (
2020
"context"
21+
"path/filepath"
2122
"testing"
2223

2324
"github.com/awslabs/soci-snapshotter/config"
@@ -80,30 +81,45 @@ func TestStoreGetContentStorePath(t *testing.T) {
8081

8182
tests := []struct {
8283
input string
84+
root string
8385
output string
8486
fail bool
8587
}{
8688
{
8789
input: "",
90+
root: "",
8891
output: defaultContentStorePath,
8992
},
9093
{
9194
input: "soci",
95+
root: "",
9296
output: DefaultSociContentStorePath,
9397
},
9498
{
9599
input: "containerd",
100+
root: "",
96101
output: DefaultContainerdContentStorePath,
97102
},
98103
{
99104
input: "bad",
105+
root: "",
100106
fail: true,
101107
},
108+
{
109+
input: "soci",
110+
root: "/tmp/test",
111+
output: filepath.Join("/tmp/test", "content"),
112+
},
113+
{
114+
input: "containerd",
115+
root: "/tmp/test",
116+
output: DefaultContainerdContentStorePath,
117+
},
102118
}
103119

104120
for _, tt := range tests {
105121
t.Run(tt.input, func(t *testing.T) {
106-
output, err := GetContentStorePath(ContentStoreType(tt.input), "")
122+
output, err := GetContentStorePath(ContentStoreType(tt.input), tt.root)
107123
if err != nil {
108124
if !tt.fail {
109125
t.Fatalf("content store type \"%s\" produced path %s with unexpected error %v", tt.input, output, err)

0 commit comments

Comments
 (0)