Skip to content

Commit 6797ba4

Browse files
zhilingcfeast-ci-bot
authored andcommitted
Fix go test (feast-dev#97)
* Fix timezone printing to be UTC * Revert timestamp printing to be timezone sensitive
1 parent 986381d commit 6797ba4

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

cli/feast/pkg/printer/printer_test.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package printer
22

33
import (
4+
"fmt"
45
"testing"
56

7+
"github.com/gojek/feast/cli/feast/pkg/util"
8+
69
"github.com/golang/protobuf/ptypes/timestamp"
710

811
"github.com/gojek/feast/protos/generated/go/feast/core"
@@ -42,7 +45,7 @@ func TestPrintFeature(t *testing.T) {
4245
LastUpdated: &timestamp.Timestamp{Seconds: 1},
4346
Created: &timestamp.Timestamp{Seconds: 1},
4447
},
45-
expected: `Id: test.none.test_feature_two
48+
expected: fmt.Sprintf(`Id: test.none.test_feature_two
4649
Entity: test
4750
Owner: bob@example.com
4851
Description: testing feature
@@ -51,11 +54,13 @@ Uri: https://github.com/bob/example
5154
DataStores:
5255
Serving: REDIS
5356
Warehouse: BIGQUERY
54-
Created: 1970-01-01T07:30:01+07:30
55-
LastUpdated: 1970-01-01T07:30:01+07:30
57+
Created: %s
58+
LastUpdated: %s
5659
Related Jobs:
5760
- job1
5861
- job2`,
62+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}),
63+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})),
5964
}, {
6065
name: "no storage",
6166
input: &core.UIServiceTypes_FeatureDetail{
@@ -74,17 +79,19 @@ Related Jobs:
7479
LastUpdated: &timestamp.Timestamp{Seconds: 1},
7580
Created: &timestamp.Timestamp{Seconds: 1},
7681
},
77-
expected: `Id: test.none.test_feature_two
82+
expected: fmt.Sprintf(`Id: test.none.test_feature_two
7883
Entity: test
7984
Owner: bob@example.com
8085
Description: testing feature
8186
ValueType: INT64
8287
Uri: https://github.com/bob/example
83-
Created: 1970-01-01T07:30:01+07:30
84-
LastUpdated: 1970-01-01T07:30:01+07:30
88+
Created: %s
89+
LastUpdated: %s
8590
Related Jobs:
8691
- job1
8792
- job2`,
93+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}),
94+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1})),
8895
},
8996
}
9097

@@ -109,13 +116,14 @@ func TestPrintEntity(t *testing.T) {
109116
LastUpdated: &timestamp.Timestamp{Seconds: 1},
110117
}
111118
out := PrintEntityDetail(entityDetail)
112-
expected := `Name: test
119+
expected := fmt.Sprintf(`Name: test
113120
Description: my test entity
114121
Tags: tag1,tag2
115-
LastUpdated: 1970-01-01T07:30:01+07:30
122+
LastUpdated: %s
116123
Related Jobs:
117124
- job1
118-
- job2`
125+
- job2`,
126+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}))
119127
if out != expected {
120128
t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out)
121129
}
@@ -134,12 +142,13 @@ func TestPrintStorage(t *testing.T) {
134142
LastUpdated: &timestamp.Timestamp{Seconds: 1},
135143
}
136144
out := PrintStorageDetail(storageDetail)
137-
expected := `Id: REDIS1
145+
expected := fmt.Sprintf(`Id: REDIS1
138146
Type: redis
139147
Options:
140148
option1: value1
141149
option2: value2
142-
LastUpdated: 1970-01-01T07:30:01+07:30`
150+
LastUpdated: %s`,
151+
util.ParseTimestamp(timestamp.Timestamp{Seconds: 1}))
143152
if out != expected {
144153
t.Errorf("Expected output:\n%s \nActual:\n%s \n", expected, out)
145154
}

0 commit comments

Comments
 (0)