forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspecs_test.go
More file actions
153 lines (145 loc) · 3.91 KB
/
Copy pathspecs_test.go
File metadata and controls
153 lines (145 loc) · 3.91 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package printer
import (
"fmt"
"testing"
"github.com/gojek/feast/cli/feast/pkg/timeutil"
"github.com/golang/protobuf/ptypes/timestamp"
"github.com/gojek/feast/protos/generated/go/feast/core"
"github.com/gojek/feast/protos/generated/go/feast/specs"
"github.com/gojek/feast/protos/generated/go/feast/types"
)
func TestPrintFeature(t *testing.T) {
tt := []struct {
name string
input *core.UIServiceTypes_FeatureDetail
expected string
}{
{
name: "with storage",
input: &core.UIServiceTypes_FeatureDetail{
Spec: &specs.FeatureSpec{
Id: "test.test_feature_two",
Owner: "bob@example.com",
Name: "test_feature_two",
Description: "testing feature",
Uri: "https://github.com/bob/example",
ValueType: types.ValueType_INT64,
Entity: "test",
DataStores: &specs.DataStores{
Serving: &specs.DataStore{
Id: "REDIS",
},
Warehouse: &specs.DataStore{
Id: "BIGQUERY",
},
},
},
BigqueryView: "bqurl",
Jobs: []string{"job1", "job2"},
LastUpdated: ×tamp.Timestamp{Seconds: 1},
Created: ×tamp.Timestamp{Seconds: 1},
},
expected: fmt.Sprintf(`Id: test.test_feature_two
Entity: test
Owner: bob@example.com
Description: testing feature
ValueType: INT64
Uri: https://github.com/bob/example
DataStores:
Serving: REDIS
Warehouse: BIGQUERY
Created: %s
LastUpdated: %s
Related Jobs:
- job1
- job2`,
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1}),
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1})),
}, {
name: "no storage",
input: &core.UIServiceTypes_FeatureDetail{
Spec: &specs.FeatureSpec{
Id: "test.test_feature_two",
Owner: "bob@example.com",
Name: "test_feature_two",
Description: "testing feature",
Uri: "https://github.com/bob/example",
ValueType: types.ValueType_INT64,
Entity: "test",
},
BigqueryView: "bqurl",
Jobs: []string{"job1", "job2"},
LastUpdated: ×tamp.Timestamp{Seconds: 1},
Created: ×tamp.Timestamp{Seconds: 1},
},
expected: fmt.Sprintf(`Id: test.test_feature_two
Entity: test
Owner: bob@example.com
Description: testing feature
ValueType: INT64
Uri: https://github.com/bob/example
Created: %s
LastUpdated: %s
Related Jobs:
- job1
- job2`,
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1}),
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1})),
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
out := PrintFeatureDetail(tc.input)
if out != tc.expected {
t.Errorf("Expected output:\n%s \nActual:\n%s \n", tc.expected, out)
}
})
}
}
func TestPrintEntity(t *testing.T) {
entityDetail := &core.UIServiceTypes_EntityDetail{
Spec: &specs.EntitySpec{
Name: "test",
Description: "my test entity",
Tags: []string{"tag1", "tag2"},
},
Jobs: []string{"job1", "job2"},
LastUpdated: ×tamp.Timestamp{Seconds: 1},
}
out := PrintEntityDetail(entityDetail)
expected := fmt.Sprintf(`Name: test
Description: my test entity
Tags: tag1,tag2
LastUpdated: %s
Related Jobs:
- job1
- job2`,
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1}))
if out != expected {
t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out)
}
}
func TestPrintStorage(t *testing.T) {
storageDetail := &core.UIServiceTypes_StorageDetail{
Spec: &specs.StorageSpec{
Id: "REDIS1",
Type: "redis",
Options: map[string]string{
"option1": "value1",
"option2": "value2",
},
},
LastUpdated: ×tamp.Timestamp{Seconds: 1},
}
out := PrintStorageDetail(storageDetail)
expected := fmt.Sprintf(`Id: REDIS1
Type: redis
Options:
option1: value1
option2: value2
LastUpdated: %s`,
timeutil.FormatToRFC3339(timestamp.Timestamp{Seconds: 1}))
if out != expected {
t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out)
}
}