forked from treeverse/lakeFS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcataloger_list_repositories_test.go
83 lines (79 loc) · 1.81 KB
/
cataloger_list_repositories_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package catalog
import (
"context"
"fmt"
"reflect"
"testing"
)
func TestCataloger_ListRepositories(t *testing.T) {
ctx := context.Background()
c := testCataloger(t)
// create test data
for i := 3; i > 0; i-- {
repoName := fmt.Sprintf("repo%d", i)
storage := fmt.Sprintf("s3://bucket%d", i)
err := c.CreateRepository(ctx, repoName, storage, "master")
if err != nil {
t.Fatal("create repository for testing failed", err)
}
}
type args struct {
limit int
after string
}
tests := []struct {
name string
args args
want []string
wantMore bool
wantErr bool
}{
{
name: "basic",
args: args{limit: -1, after: ""},
want: []string{"repo1", "repo2", "repo3"},
wantMore: false,
wantErr: false,
},
{
name: "small amount",
args: args{limit: 1, after: ""},
want: []string{"repo1"},
wantMore: true,
wantErr: false,
},
{
name: "the rest",
args: args{limit: 10, after: "repo2"},
want: []string{"repo3"},
wantMore: false,
wantErr: false,
},
{
name: "nothing to be found",
args: args{limit: 0, after: "repoX"},
want: nil,
wantMore: false,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, gotMore, err := c.ListRepositories(ctx, tt.args.limit, tt.args.after)
if (err != nil) != tt.wantErr {
t.Errorf("ListRepositories() error = %v, wantErr %v", err, tt.wantErr)
return
}
var names []string
for _, repository := range got {
names = append(names, repository.Name)
}
if !reflect.DeepEqual(tt.want, names) {
t.Errorf("ListRepositories() got repos = %v, want %v", names, tt.want)
}
if gotMore != tt.wantMore {
t.Errorf("ListRepositories() got more = %v, want %v", gotMore, tt.wantMore)
}
})
}
}