Skip to content

Commit 2afae11

Browse files
committed
Raise FS option unit test coverage
1 parent 57b567d commit 2afae11

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package azure
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestWithClient(t *testing.T) {
11+
client := &DefaultClient{}
12+
fs := &FileSystem{}
13+
14+
opt := WithClient(client)
15+
opt.Apply(fs)
16+
17+
assert.Equal(t, client, fs.client, "Client should be set correctly")
18+
}
19+
20+
func TestWithOptions(t *testing.T) {
21+
options := Options{}
22+
fs := &FileSystem{}
23+
24+
opt := WithOptions(options)
25+
opt.Apply(fs)
26+
27+
assert.Equal(t, options, *fs.options, "Options should be set correctly")
28+
}
29+
30+
func TestWithContext(t *testing.T) {
31+
ctx := context.Background()
32+
fs := &FileSystem{}
33+
34+
opt := WithContext(ctx)
35+
opt.Apply(fs)
36+
37+
assert.Equal(t, ctx, fs.ctx, "Context should be set correctly")
38+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package ftp
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/jlaffaye/ftp"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestWithClient(t *testing.T) {
12+
client := &ftp.ServerConn{}
13+
fs := &FileSystem{}
14+
15+
opt := WithClient(client)
16+
opt.Apply(fs)
17+
18+
assert.Equal(t, client, fs.ftpclient, "Client should be set correctly")
19+
}
20+
21+
func TestWithOptions(t *testing.T) {
22+
options := Options{}
23+
fs := &FileSystem{}
24+
25+
opt := WithOptions(options)
26+
opt.Apply(fs)
27+
28+
assert.Equal(t, options, fs.options, "Options should be set correctly")
29+
}
30+
31+
func TestWithContext(t *testing.T) {
32+
ctx := context.Background()
33+
fs := &FileSystem{}
34+
35+
opt := WithContext(ctx)
36+
opt.Apply(fs)
37+
38+
assert.Equal(t, ctx, fs.ctx, "Context should be set correctly")
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package s3
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/aws/aws-sdk-go-v2/service/s3"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestWithClient(t *testing.T) {
12+
client := &s3.Client{}
13+
fs := &FileSystem{}
14+
15+
opt := WithClient(client)
16+
opt.Apply(fs)
17+
18+
assert.Equal(t, client, fs.client, "Client should be set correctly")
19+
}
20+
21+
func TestWithOptions(t *testing.T) {
22+
options := Options{}
23+
fs := &FileSystem{}
24+
25+
opt := WithOptions(options)
26+
opt.Apply(fs)
27+
28+
assert.Equal(t, options, fs.options, "Options should be set correctly")
29+
}
30+
31+
func TestWithContext(t *testing.T) {
32+
ctx := context.Background()
33+
fs := &FileSystem{}
34+
35+
opt := WithContext(ctx)
36+
opt.Apply(fs)
37+
38+
assert.Equal(t, ctx, fs.ctx, "Context should be set correctly")
39+
}

0 commit comments

Comments
 (0)