Skip to content

Commit 4d9d133

Browse files
committed
Added unit test for fluent modifiers
1 parent 82bdb22 commit 4d9d133

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

table/options/models_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package options
2+
3+
import (
4+
"reflect"
5+
"testing"
6+
"time"
7+
)
8+
9+
func TestTimeToLiveSettingsFluentModifiers(t *testing.T) {
10+
for _, tt := range []struct {
11+
fluentSettings TimeToLiveSettings
12+
expectedSettings TimeToLiveSettings
13+
}{
14+
{
15+
fluentSettings: TimeToLiveSettings{}.
16+
WithColumnName("a").
17+
WithColumnUnit(TimeToLiveUnitSeconds).
18+
WithMode(TimeToLiveModeValueSinceUnixEpoch).
19+
WithExpireAfter(time.Hour),
20+
expectedSettings: TimeToLiveSettings{
21+
ColumnName: "a",
22+
Mode: TimeToLiveModeValueSinceUnixEpoch,
23+
ExpireAfterSeconds: uint32(time.Hour.Seconds()),
24+
ColumnUnit: func() *TimeToLiveUnit {
25+
u := TimeToLiveUnitSeconds
26+
return &u
27+
}(),
28+
},
29+
},
30+
} {
31+
t.Run("", func(t *testing.T) {
32+
if !reflect.DeepEqual(tt.fluentSettings, tt.expectedSettings) {
33+
t.Errorf("unexpected ttl settings: %v, expectedSettings: %v", tt.fluentSettings, tt.expectedSettings)
34+
}
35+
})
36+
}
37+
}

0 commit comments

Comments
 (0)